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

populate(message: Message, signatures: Array<string>): Transaction

Populate Transaction object from message and signatures

Constructor Summary

Public Constructor
public

Construct an empty Transaction

Member Summary

Public Members
public

The transaction fee payer

public

The instructions to atomically execute

public

Optional Nonce information.

public

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

addSignature(pubkey: PublicKey, signature: Buffer)

Add an externally created signature to a transaction.

public

Compile transaction data

public

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

Partially sign a transaction with the specified accounts.

public

serialize(config: SerializeConfig): Buffer

Serialize the Transaction in the wire format.

public

serializeMessage(): Buffer

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

public

setSigners(signers: ...Array<PublicKey>)

this method was deprecated. 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.

Specify the public keys which will be used to sign the Transaction.

public

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

Sign the Transaction with the specified accounts.

public

Verify signatures of a complete, signed Transaction

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 populate(message: Message, signatures: Array<string>): Transaction source

Populate Transaction object from message and signatures

Params:

NameTypeAttributeDescription
message Message
signatures Array<string>

Return:

Transaction

Public Constructors

public constructor(opts: TransactionCtorFields) source

Construct an empty Transaction

Params:

NameTypeAttributeDescription
opts TransactionCtorFields

Public Members

public feePayer: PublicKey source

The transaction fee payer

public instructions: Array<TransactionInstruction> source

The instructions to atomically execute

public nonceInfo: NonceInformation 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 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 addSignature(pubkey: PublicKey, signature: Buffer) source

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.

Params:

NameTypeAttributeDescription
pubkey PublicKey
signature Buffer

public compileMessage(): Message source

Compile transaction data

Return:

Message

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

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

Params:

NameTypeAttributeDescription
signers ...Array<Account>

public serialize(config: SerializeConfig): Buffer source

Serialize the Transaction in the wire format.

Params:

NameTypeAttributeDescription
config SerializeConfig

Return:

Buffer

public serializeMessage(): Buffer source

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

Return:

Buffer

public setSigners(signers: ...Array<PublicKey>) source

this method was deprecated. 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.

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

Params:

NameTypeAttributeDescription
signers ...Array<PublicKey>

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 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

Params:

NameTypeAttributeDescription
signers ...Array<Account>

public verifySignatures(): boolean source

Verify signatures of a complete, signed Transaction

Return:

boolean