Broadcasting

Learn how to broadcast transactions to the Stacks network.

Broadcasting Transactions

A finalized transaction can be broadcasted to the network or serialized (to a byte representation) using Stacks.js.

import { bytesToHex } from '@stacks/common';
import {
  makeSTXTokenTransfer,
  broadcastTransaction,
  AnchorMode,
} from '@stacks/transactions';

const broadcastResponse = await broadcastTransaction(transaction);
const txId = broadcastResponse.txid;

const serializedTx = tx.serialize();
const serializedTxHex = bytesToHex(serializedTx);
Info
For web applications, user wallets can broadcast transactions via @stacks/connect.