Transaction class

Constructors

Properties

feePayer?: PublicKey

The transaction fee payer

instructions: TransactionInstruction[] = []

The instructions to atomically execute

lastValidBlockHeight?: number

the last block chain can advance to before tx is declared expired

minNonceContextSlot?: number

If this is a nonce transaction this represents the minimum slot from which to evaluate if the nonce has advanced when attempting to confirm the transaction. This protects against a case where the transaction confirmation logic loads the nonce account from an old slot and assumes the mismatch in nonce value implies that the nonce has been advanced.

nonceInfo?: NonceInformation

Optional Nonce information. If populated, transaction will use a durable Nonce hash instead of a recentBlockhash. Must be populated by the caller

recentBlockhash?: string

A recent transaction id. Must be populated by the caller

signatures: SignaturePubkeyPair[] = []

Signatures for the transaction. Typically created by invoking the sign() method

Accessors

  • get signature(): null | Buffer
  • The first (payer) Transaction signature

    Returns null | Buffer

    Buffer of payer's signature

Methods

  • Add an externally created signature to a transaction. The public key must correspond to either the fee payer or a signer account in the transaction instructions.

    Parameters

    • pubkey: PublicKey

      Public key that will be added to the transaction.

    • signature: Buffer

      An externally created signature to add to the transaction.

    Returns void

  • Get the estimated fee associated with a transaction

    Parameters

    • connection: Connection

      Connection to RPC Endpoint.

    Returns Promise<null | number>

    The estimated fee for the transaction

  • Partially sign a transaction with the specified accounts. All accounts must correspond to either the fee payer or a signer account in the transaction instructions.

    All the caveats from the sign method apply to partialSign

    Parameters

    • Rest...signers: Signer[]

      Array of signers that will sign the transaction

    Returns void

  • Serialize the Transaction in the wire format.

    Parameters

    Returns Buffer

    Signature of transaction in wire format.

  • Get a buffer of the Transaction data that need to be covered by signatures

    Returns Buffer

  • Specify the public keys which will be used to sign the Transaction. The first signer will be used as the transaction fee payer account.

    Signatures can be added with either partialSign or addSignature

    Parameters

    Returns void

    Deprecated since v0.84.0. Only the fee payer needs to be specified and it can be set in the Transaction constructor or with the feePayer property.

  • Sign the Transaction with the specified signers. Multiple signatures may be applied to a Transaction. The first signature is considered "primary" and is used identify and confirm transactions.

    If the Transaction feePayer is not set, the first signer will be used as the transaction fee payer account.

    Transaction fields should not be modified after the first call to sign, as doing so may invalidate the signature and cause the Transaction to be rejected.

    The Transaction must be assigned a valid recentBlockhash before invoking this method

    Parameters

    • Rest...signers: Signer[]

      Array of signers that will sign the transaction

    Returns void

  • Verify signatures of a Transaction Optional parameter specifies if we're expecting a fully signed Transaction or a partially signed one. If no boolean is provided, we expect a fully signed Transaction by default.

    Parameters

    • OptionalrequireAllSignatures: boolean = true

      Require a fully signed Transaction

    Returns boolean

  • Parse a wire transaction into a Transaction object.

    Parameters

    • buffer: number[] | Uint8Array | Buffer

      Signature of wire Transaction

    Returns Transaction

    Transaction associated with the signature

  • Populate Transaction object from message and signatures

    Parameters

    • message: Message

      Message of transaction

    • signatures: string[] = []

      List of signatures to assign to the transaction

    Returns Transaction

    The populated Transaction