Skip to main content
Version: v4.0.0-nightly.20260204

Sending Transactions

This guide shows you how to send transactions to smart contracts on Aztec.

Overview

Transactions on Aztec execute contract functions that modify state. Unlike simple reads, transactions go through private execution on your device, proving, and then submission to the network for inclusion in a block. You can send single transactions, batch multiple calls atomically, and query transaction status after submission.

Prerequisites

Send a transaction

After connecting to a contract:

import { Contract } from "@aztec/aztec.js";

// wallet is from the connection guide; contractAddress and artifact are from your deployed contract
const contract = await Contract.at(contractAddress, artifact, wallet);

Call a function and wait for it to be mined:

// contract is from the step above; alice is from the connection guide
const receipt = await contract.methods
.transfer(bobAddress, amount)
.send({ from: aliceAddress });

console.log(`Transaction mined in block ${receipt.blockNumber}`);
console.log(`Transaction fee: ${receipt.transactionFee}`);

The from field specifies which account sends the transaction. If that account has Fee Juice, it pays for the transaction automatically. For other fee payment options, see paying fees.

Send without waiting

Use the NO_WAIT option to get the transaction hash immediately without waiting for inclusion:

no_wait_transaction
// Use NO_WAIT for regular transactions too
const transferTxHash = await token.methods
.transfer(bobAddress, 100n)
.send({ from: aliceAddress, wait: NO_WAIT });

console.log(`Transaction sent: ${transferTxHash.toString()}`);

// Wait for inclusion later using the node
const transferReceipt = await waitForTx(node, transferTxHash);
console.log(`Transaction mined in block ${transferReceipt.blockNumber}`);
Source code: docs/examples/ts/aztecjs_advanced/index.ts#L146-L157

Send batch transactions

Execute multiple calls atomically using BatchCall:

batch_call
// Execute multiple calls atomically using BatchCall
const batch = new BatchCall(wallet, [
token.methods.mint_to_public(aliceAddress, 500n),
token.methods.transfer(bobAddress, 200n),
]);

const batchReceipt = await batch.send({ from: aliceAddress });
console.log(`Batch executed in block ${batchReceipt.blockNumber}`);
Source code: docs/examples/ts/aztecjs_advanced/index.ts#L159-L168
warning

All calls in a batch must succeed or the entire batch reverts. Use batch transactions when you need atomic execution of multiple operations.

Query transaction status

After sending a transaction without waiting, you can query its receipt using the node:

query_tx_status
// Query transaction status after sending without waiting
const statusTxHash = await token.methods
.transfer(bobAddress, 10n)
.send({ from: aliceAddress, wait: NO_WAIT });

// Check status using the node
const txReceipt = await node.getTxReceipt(statusTxHash);

console.log(`Status: ${txReceipt.status}`);
console.log(`Block number: ${txReceipt.blockNumber}`);
console.log(`Transaction fee: ${txReceipt.transactionFee}`);
Source code: docs/examples/ts/aztecjs_advanced/index.ts#L191-L203

The receipt includes:

  • status - Transaction status (success, reverted, dropped, or pending)
  • blockNumber - Block where the transaction was included
  • transactionFee - Fee paid for the transaction
  • error - Error message if the transaction reverted

Next steps