Class: Solace::Instructions::SystemProgram::CreateAccountInstruction
- Inherits:
-
Object
- Object
- Solace::Instructions::SystemProgram::CreateAccountInstruction
- Defined in:
- lib/solace/instructions/system_program/create_account_instruction.rb
Overview
Instruction for creating a new account.
This instruction is used to create a new account for a given program.
Constant Summary collapse
- INSTRUCTION_INDEX =
[0, 0, 0, 0].freeze
Instance Attribute Summary collapse
-
#INSTRUCTION_INDEX ⇒ Object
readonly
Instruction index for SystemProgram::CreateAccount This is the same across all Solana clusters.
Class Method Summary collapse
-
.build(space:, lamports:, from_index:, new_account_index:, owner: Solace::Constants::SYSTEM_PROGRAM_ID, system_program_index: 2) ⇒ Solace::Instruction
Builds a SystemProgram::CreateAccount instruction.
-
.data(lamports, space, owner) ⇒ Array
Builds the data for a SystemProgram::CreateAccount instruction.
Instance Attribute Details
#INSTRUCTION_INDEX ⇒ Object (readonly)
Instruction index for SystemProgram::CreateAccount This is the same across all Solana clusters
25 |
# File 'lib/solace/instructions/system_program/create_account_instruction.rb', line 25 INSTRUCTION_INDEX = [0, 0, 0, 0].freeze |
Class Method Details
.build(space:, lamports:, from_index:, new_account_index:, owner: Solace::Constants::SYSTEM_PROGRAM_ID, system_program_index: 2) ⇒ Solace::Instruction
Builds a SystemProgram::CreateAccount instruction
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/solace/instructions/system_program/create_account_instruction.rb', line 36 def self.build( space:, lamports:, from_index:, new_account_index:, owner: Solace::Constants::SYSTEM_PROGRAM_ID, system_program_index: 2 ) Solace::Instruction.new.tap do |ix| ix.program_index = system_program_index ix.accounts = [from_index, new_account_index] ix.data = data(lamports, space, owner) end end |
.data(lamports, space, owner) ⇒ Array
Builds the data for a SystemProgram::CreateAccount instruction
The BufferLayout is:
- [Instruction Index (4 bytes)]
- [Lamports (8 bytes)]
- [Space (8 bytes)]
- [Owner (32 bytes)]
64 65 66 67 68 69 |
# File 'lib/solace/instructions/system_program/create_account_instruction.rb', line 64 def self.data(lamports, space, owner) INSTRUCTION_INDEX + Solace::Utils::Codecs.encode_le_u64(lamports).bytes + Solace::Utils::Codecs.encode_le_u64(space).bytes + Solace::Utils::Codecs.base58_to_bytes(owner) end |