Skip to main content

How to Deploy a Contract

This guide explains how to deploy a smart contract using Aztec.js.

Prerequisites

You should have a wallet to act as the deployer, and a contract artifact ready to be deployed.

You can learn how to create wallets from this guide.

You can read about contract artifacts here.

Import the contract artifact

In this guide we are using a Token contract artifact. This comes from the token contract tutorial.

import_token_contract
import { TokenContract, TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
Source code: yarn-project/end-to-end/src/composed/docs_examples.test.ts#L8-L11

Deploy contract

deploy_contract
const deployedContract = await TokenContract.deploy(
wallet, // wallet instance
wallet.getAddress(), // account
'TokenName', // constructor arg1
'TokenSymbol', // constructor arg2
18,
) // constructor arg3
.send()
.deployed();
Source code: yarn-project/end-to-end/src/composed/docs_examples.test.ts#L26-L36

To learn how to send a transaction from Aztec.js read this guide. You can also call a view function from Aztec.js by reading this guide.