Home Reference Source
import {Transaction} from '@solana/web3'
public class | source

Transaction

Transaction class

Static Method Summary

Static Public Methods
public static

from(buffer: Buffer | Uint8Array | Array<number>): Transaction

Parse a wire transaction into a Transaction object.

public static

fromRpcResult(rpcResult: any): Transaction

Parse an RPC result into a Transaction object.

Constructor Summary

Public Constructor
public

Construct an empty Transaction

Member Summary

Public Members
public

The instructions to atomically execute

public

nonceInfo: NonceInformation | nullliteral

Optional Nonce information.

public

recentBlockhash: Blockhash | nullliteral

A recent transaction id.

public get

signature: Buffer | nullliteral

The first (payer) Transaction signature

public

signatures: Array<SignaturePubkeyPair>

Signatures for the transaction.

Method Summary

Public Methods
public

Add one or more instructions to this Transaction

public

addSigner(signer: Account)

Fill in a signature for a partially signed Transaction.

public

serialize(): Buffer

Serialize the Transaction in the wire format.

public

sign(signers: ...Array<Account>)

Sign the Transaction with the specified accounts.

public

signPartial(partialSigners: ...Array<PublicKey|Account>)

Partially sign a Transaction with the specified accounts.

Static Public Methods

public static from(buffer: Buffer | Uint8Array | Array<number>): Transaction source

Parse a wire transaction into a Transaction object.

Params:

NameTypeAttributeDescription
buffer Buffer | Uint8Array | Array<number>

Return:

Transaction

public static fromRpcResult(rpcResult: any): Transaction source

Parse an RPC result into a Transaction object.

Params:

NameTypeAttributeDescription
rpcResult any

Return:

Transaction

Public Constructors

public constructor(opts: TransactionCtorFields) source

Construct an empty Transaction

Params:

NameTypeAttributeDescription
opts TransactionCtorFields

Public Members

public instructions: Array<TransactionInstruction> source

The instructions to atomically execute

public nonceInfo: NonceInformation | nullliteral source

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

public recentBlockhash: Blockhash | nullliteral source

A recent transaction id. Must be populated by the caller

public get signature: Buffer | nullliteral source

The first (payer) Transaction signature

public signatures: Array<SignaturePubkeyPair> source

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

Public Methods

public add(items: ...Array<Transaction|TransactionInstruction|TransactionInstructionCtorFields>): Transaction source

Add one or more instructions to this Transaction

Params:

NameTypeAttributeDescription
items ...Array<Transaction|TransactionInstruction|TransactionInstructionCtorFields>

Return:

Transaction

public addSigner(signer: Account) source

Fill in a signature for a partially signed Transaction. The signer must be the corresponding Account for a PublicKey that was previously provided to signPartial

Params:

NameTypeAttributeDescription
signer Account

public serialize(): Buffer source

Serialize the Transaction in the wire format.

The Transaction must have a valid signature before invoking this method

Return:

Buffer

public sign(signers: ...Array<Account>) source

Sign the Transaction with the specified accounts. Multiple signatures may be applied to a Transaction. The first signature is considered "primary" and is used when testing for Transaction confirmation.

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

Params:

NameTypeAttributeDescription
signers ...Array<Account>

public signPartial(partialSigners: ...Array<PublicKey|Account>) source

Partially sign a Transaction with the specified accounts. The Account inputs will be used to sign the Transaction immediately, while any PublicKey inputs will be referenced in the signed Transaction but need to be filled in later by calling addSigner() with the matching Account.

All the caveats from the sign method apply to signPartial

Params:

NameTypeAttributeDescription
partialSigners ...Array<PublicKey|Account>