Skip to main content
Version: Testnet (v2.0.4)

How to Send a Transaction

This guide explains how to send a transaction using Aztec.js.

Prerequisites

You should have a wallet to act as the transaction sender, a contract that has been deployed, and fee juice to pay for transactions.

You can learn how to create wallets from this guide.

You can learn how to deploy a contract here.

You can learn how to use fee juice here.

Relevant imports

You will need to import this library:

import_contract
import { Contract } from "@aztec/aztec.js";
Source code: yarn-project/end-to-end/src/composed/docs_examples.test.ts#L7-L9

Define contract

Get a previously deployed contract like this:

get_contract
const contract = await Contract.at(
deployedContract.address,
TokenContractArtifact,
wallet
);
Source code: yarn-project/end-to-end/src/composed/docs_examples.test.ts#L46-L48

Call method

send_transaction
await contract.methods
.mint_to_public(newAccountAddress, 1)
.send({ from: defaultAccountAddress })
.wait();
Source code: yarn-project/end-to-end/src/composed/docs_examples.test.ts#L51-L53