Solana.Transaction (Solana v0.2.0) View Source

Functions for building and encoding Solana transactions

Link to this section Summary

Types

The possible errors encountered when encoding a transaction.

t()

All the details needed to encode a transaction.

Functions

Checks to see if a transaction's signature is valid.

decodes a base58-encoded signature and returns it in a tuple.

decodes a base58-encoded signature and returns it.

Parses a Solana.Transaction.t/0 from data encoded in Solana's binary format

Link to this section Types

Specs

encoding_err() ::
  :no_payer
  | :no_blockhash
  | :no_program
  | :no_instructions
  | :mismatched_signers

The possible errors encountered when encoding a transaction.

Specs

t() :: %Solana.Transaction{
  blockhash: binary() | nil,
  instructions: [Solana.Instruction.t()],
  payer: Solana.key() | nil,
  signers: [Solana.keypair()]
}

All the details needed to encode a transaction.

Link to this section Functions

Specs

check(binary()) :: {:ok, binary()} | {:error, :invalid_signature}

Checks to see if a transaction's signature is valid.

Returns {:ok, signature} if it is, and an error tuple if it isn't.

Specs

decode(encoded :: binary()) :: {:ok, binary()} | {:error, binary()}

decodes a base58-encoded signature and returns it in a tuple.

If it fails, return an error tuple.

Specs

decode!(encoded :: binary()) :: binary()

decodes a base58-encoded signature and returns it.

Throws an ArgumentError if it fails.

Specs

parse(encoded :: binary()) :: {t(), keyword()} | :error

Parses a Solana.Transaction.t/0 from data encoded in Solana's binary format

Returns {transaction, extras} if the transaction was successfully parsed, or :error if the provided binary could not be parsed. extras is a keyword list containing information about the encoded transaction, namely:

Specs

to_binary(tx :: t()) :: {:ok, binary()} | {:error, encoding_err()}

Encodes a Solana.Transaction.t/0 into a binary format

Returns {:ok, encoded_transaction} if the transaction was successfully encoded, or an error tuple if the encoding failed -- plus more error details via Logger.error/1.