StacksTransactionWire

The core class representing a Stacks transaction. Contains the transaction's version, chain ID, authorization, payload, and post conditions. Returned by all builder functions.


Usage

import {
  makeSTXTokenTransfer,
  StacksTransactionWire,
} from '@stacks/transactions';

const transaction = await makeSTXTokenTransfer({
  recipient: 'ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5',
  amount: 1000000n,
  senderKey: 'b244296d5907de9864c0b0d51f98a13c52890be0404e83f273144004b81874603',
  network: 'testnet',
});

// Serialize to hex
const hex = transaction.serialize();

// Serialize to bytes
const bytes = transaction.serializeBytes();

// Get transaction ID
const txid = transaction.txid();

// Modify fee and nonce
transaction.setFee(5000n);
transaction.setNonce(10n);

Reference Linkarrow-up-right


Definition


Instance Methods

serialize

Serializes the transaction to a hex string.

serializeBytes

Serializes the transaction to a Uint8Array.

txid

Computes and returns the transaction ID.

setFee

Sets the transaction fee (in microSTX).

setNonce

Sets the transaction nonce.

setSponsor

Sets the sponsor spending condition (for sponsored transactions).

setSponsorNonce

Sets the sponsor's nonce (for sponsored transactions).

verifyOrigin

Verifies the origin's signature(s) on the transaction.

appendPubkey

Appends a public key to the spending condition (for multi-sig transactions).

Last updated

Was this helpful?