Class: Solace::Instruction

Inherits:
Object
  • Object
show all
Includes:
Concerns::BinarySerializable
Defined in:
lib/solace/instruction.rb

Overview

Class representing a Solana instruction.

Handles serialization and deserialization of instruction fields. Instructions are used to encode the data that is sent to a program on the Solana blockchain. Instructions are part of transaction messages. All instruction builders and instruction composers return an instance of this class.

The BufferLayout is:

- [Program index (1 byte)]
- [Number of accounts (compact u16)]
- [Accounts (variable length)]
- [Data length (compact u16)]
- [Data (variable length)]

Examples:

instruction = Solace::Instruction.new(
  program_index: 0,
  accounts: [1, 2, 3],
  data: [4, 5, 6]
)

Since:

  • 0.0.1

Constant Summary collapse

SERIALIZER =

Since:

  • 0.0.1

Solace::Serializers::InstructionSerializer
DESERIALIZER =

Since:

  • 0.0.1

Solace::Serializers::InstructionDeserializer

Instance Attribute Summary collapse

Method Summary

Methods included from Concerns::BinarySerializable

included, #serialize, #to_binary, #to_bytes, #to_io

Instance Attribute Details

#accountsArray<Integer>

Returns The accounts of the instruction.

Returns:

  • (Array<Integer>)

    The accounts of the instruction



43
44
45
# File 'lib/solace/instruction.rb', line 43

def accounts
  @accounts
end

#dataArray<Integer>

Returns The instruction data.

Returns:

  • (Array<Integer>)

    The instruction data



47
48
49
# File 'lib/solace/instruction.rb', line 47

def data
  @data
end

#DESERIALIZERSolace::Serializers::InstructionDeserializer

Returns The deserializer for the instruction.

Returns:



35
# File 'lib/solace/instruction.rb', line 35

DESERIALIZER = Solace::Serializers::InstructionDeserializer

#program_indexInteger

Returns The program index of the instruction.

Returns:

  • (Integer)

    The program index of the instruction



39
40
41
# File 'lib/solace/instruction.rb', line 39

def program_index
  @program_index
end

#SERIALIZERSolace::Serializers::InstructionSerializer

Returns The serializer for the instruction.

Returns:



31
# File 'lib/solace/instruction.rb', line 31

SERIALIZER = Solace::Serializers::InstructionSerializer