agora.solana package

Subpackages

Submodules

agora.solana.address module

exception agora.solana.address.InvalidPublicKeyError[source]

Bases: Exception

Raised when an invalid public key is generated.

agora.solana.address.create_program_address(program, seeds)[source]

Mirrors the implementation of the Solana SDK’s CreateProgramAddress. ProgramAddresses are public keys that _do not_ lie on the ed25519 curve to ensure that there is no associated private key. In the event that the program and seed parameters result in a valid Public key, InvalidPublicKeyError is raised.

Reference: https://github.com/solana-labs/solana/blob/5548e599fe4920b71766e0ad1d121755ce9c63d5/sdk/program/src/pubkey.rs#L158

:return PublicKey

Return type:

PublicKey

agora.solana.address.find_program_address(program, seeds)[source]

FindProgramAddress mirrors the implementation of the Solana SDK’s FindProgramAddress. Its primary use case (for Kin and Agora) is for deriving associated accounts.

return: PublicKey

Return type:

Optional[PublicKey]

agora.solana.commitment module

class agora.solana.commitment.Commitment(value)[source]

Bases: enum.IntEnum

Used to indicate to Solana nodes which bank state to query. See: https://docs.solana.com/apps/jsonrpc-api#configuring-state-commitment

RECENT: The node will query its most recent block. SINGLE: The node will query the most recent block that has been voted on by supermajority of the cluster. ROOT: The node will query the most recent block having reached maximum lockout on this node. MAX: The node will query the most recent block confirmed by supermajority of the cluster as having reached maximum

lockout.

MAX = 3
RECENT = 0
ROOT = 2
SINGLE = 1
to_proto()[source]
Return type:

EnumTypeWrapper

agora.solana.instruction module

class agora.solana.instruction.AccountMeta(public_key, is_signer=False, is_writable=False, is_payer=False, is_program=False)[source]

Bases: object

Represents the account information required for building transactions.

classmethod new(pub, is_signer)[source]

Creates a new AccountMeta representing a writable account.

Parameters:
  • pub (PublicKey) – the PublicKey of the account.

  • is_signer (bool) – indicates whether this account is a signer.

Return type:

AccountMeta

classmethod new_read_only(pub, is_signer)[source]

Creates a new AccountMeta <AccountMeta representing a read-only account.

Parameters:
  • pub (PublicKey) – the PublicKey of the account.

  • is_signer (bool) – indicates whether this account is a signer.

Return type:

AccountMeta

Returns:

class agora.solana.instruction.CompiledInstruction(program_index, accounts, data)[source]

Bases: object

Represents a compiled transaction instruction

class agora.solana.instruction.Instruction(program, data, accounts=None)[source]

Bases: object

Represents a transaction instruction.

agora.solana.shortvec module

agora.solana.shortvec.decode_length(b)[source]

Decodes a shortvec-encoded length from the provided bytes

Parameters:

b (bytes) – The provided bytes

Return type:

Tuple[int, int]

Returns:

The length decoded from the provided bytes and how many bytes it used.

agora.solana.shortvec.encode_length(b, length)[source]

Encodes the specified length into the byte array.

Parameters:
  • b (bytearray) – The byte array to encode the len into.

  • length (int) – The length to encode. Must not exceed 2**16-1.

Return type:

int

Returns:

The number of bytes written to the array.

agora.solana.transaction module

class agora.solana.transaction.Header(num_signatures, num_read_only_signed, num_read_only)[source]

Bases: object

class agora.solana.transaction.Message(header, accounts, recent_blockhash, instructions)[source]

Bases: object

marshal()[source]
Return type:

bytes

classmethod unmarshal(b)[source]
Return type:

Message

class agora.solana.transaction.Transaction(signatures, message)[source]

Bases: object

get_signature()[source]

Returns the first (payer) Transaction signature

Return type:

Optional[bytes]

Returns:

The signature, if present, or None

marshal()[source]
Return type:

bytes

classmethod new(payer, instructions)[source]
set_blockhash(blockhash)[source]
sign(signers)[source]
classmethod unmarshal(b)[source]
Return type:

Transaction

Module contents

class agora.solana.Commitment(value)[source]

Bases: enum.IntEnum

Used to indicate to Solana nodes which bank state to query. See: https://docs.solana.com/apps/jsonrpc-api#configuring-state-commitment

RECENT: The node will query its most recent block. SINGLE: The node will query the most recent block that has been voted on by supermajority of the cluster. ROOT: The node will query the most recent block having reached maximum lockout on this node. MAX: The node will query the most recent block confirmed by supermajority of the cluster as having reached maximum

lockout.

MAX = 3
RECENT = 0
ROOT = 2
SINGLE = 1
to_proto()[source]
Return type:

EnumTypeWrapper

class agora.solana.Instruction(program, data, accounts=None)[source]

Bases: object

Represents a transaction instruction.

class agora.solana.Transaction(signatures, message)[source]

Bases: object

get_signature()[source]

Returns the first (payer) Transaction signature

Return type:

Optional[bytes]

Returns:

The signature, if present, or None

marshal()[source]
Return type:

bytes

classmethod new(payer, instructions)[source]
set_blockhash(blockhash)[source]
sign(signers)[source]
classmethod unmarshal(b)[source]
Return type:

Transaction

agora.solana.create_account(subsidizer, address, owner, lamports, size)[source]
Account references
  1. [WRITE, SIGNER] Funding account

  2. [WRITE, SIGNER] New account

CreateAccount {

// Number of lamports to transfer to the new account lamports: u64, // Number of bytes of memory to allocate space: u64,

// Address of program that will own the new account owner: Pubkey,

}

Return type:

Instruction

agora.solana.create_program_address(program, seeds)[source]

Mirrors the implementation of the Solana SDK’s CreateProgramAddress. ProgramAddresses are public keys that _do not_ lie on the ed25519 curve to ensure that there is no associated private key. In the event that the program and seed parameters result in a valid Public key, InvalidPublicKeyError is raised.

Reference: https://github.com/solana-labs/solana/blob/5548e599fe4920b71766e0ad1d121755ce9c63d5/sdk/program/src/pubkey.rs#L158

:return PublicKey

Return type:

PublicKey

agora.solana.decompile_create_account(m, index)[source]
Return type:

DecompiledCreateAccount

agora.solana.decompile_initialize_account(m, index)[source]
Return type:

DecompiledInitializeAccount

agora.solana.decompile_memo(m, index)[source]
Return type:

DecompiledMemo

agora.solana.decompile_transfer(m, index)[source]
Return type:

DecompiledTransfer

agora.solana.find_program_address(program, seeds)[source]

FindProgramAddress mirrors the implementation of the Solana SDK’s FindProgramAddress. Its primary use case (for Kin and Agora) is for deriving associated accounts.

return: PublicKey

Return type:

Optional[PublicKey]

agora.solana.initialize_account(account, mint, owner)[source]

// Accounts expected by this instruction: // // 0. [writable] The account to initialize. // 1. [] The mint this account will be associated with. // 2. [] The new account’s owner/multisignature. // 3. [] Rent sysvar

Return type:

Instruction

Returns:

agora.solana.memo_instruction(data)[source]
Return type:

Instruction

agora.solana.transfer(source, dest, owner, amount)[source]

// Accounts expected by this instruction: // // * Single owner/delegate // 0. [writable] The source account. // 1. [writable] The destination account. // 2. [signer] The source account’s owner/delegate. // // * Multisignature owner/delegate // 0. [writable] The source account. // 1. [writable] The destination account. // 2. [] The source account’s multisignature owner/delegate. // 3. ..3+M [signer] M signer accounts. :rtype: Instruction :return: