Class: Solace::Instructions::SystemProgram::CreateAccountInstruction
- Inherits:
-
Object
- Object
- Solace::Instructions::SystemProgram::CreateAccountInstruction
- Defined in:
- lib/solace/instructions/system_program/create_account_instruction.rb
Constant Summary collapse
- INSTRUCTION_INDEX =
!@const INSTRUCTION_INDEX
Instruction index for SystemProgram::CreateAccount This is the same across all Solana clusters [0, 0, 0, 0].freeze
Class Method Summary collapse
-
.build(space:, lamports:, owner: Solace::Constants::SYSTEM_PROGRAM_ID, from_index:, new_account_index:, system_program_index: 2) ⇒ Solace::Instruction
Builds a SystemProgram::CreateAccount instruction.
-
.data(lamports, space, owner) ⇒ Array
Builds the data for a SystemProgram::CreateAccount instruction.
Class Method Details
.build(space:, lamports:, owner: Solace::Constants::SYSTEM_PROGRAM_ID, from_index:, new_account_index:, system_program_index: 2) ⇒ Solace::Instruction
Builds a SystemProgram::CreateAccount instruction
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/solace/instructions/system_program/create_account_instruction.rb', line 22 def self.build( space:, lamports:, owner: Solace::Constants::SYSTEM_PROGRAM_ID, from_index:, new_account_index:, 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)]
49 50 51 52 53 54 |
# File 'lib/solace/instructions/system_program/create_account_instruction.rb', line 49 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 |