|
| 1 | +--- |
| 2 | +title: Getting Started on Testnet |
| 3 | +sidebar_position: 1 |
| 4 | +tags: [testnet] |
| 5 | +description: Deploy contracts and send transactions on the Aztec testnet using the CLI wallet and the Sponsored FPC for fee payment. |
| 6 | +--- |
| 7 | + |
| 8 | +import { General } from '@site/src/components/Snippets/general_snippets'; |
| 9 | + |
| 10 | +This guide walks you through deploying your first contract on the Aztec testnet. You will install the CLI tools, create an account using the Sponsored FPC (so you don't need to bridge Fee Juice yourself), and deploy and interact with a contract. |
| 11 | + |
| 12 | +## Testnet vs Local Network |
| 13 | + |
| 14 | +| Feature | Local Network | Testnet | |
| 15 | +|---------|-------------|---------| |
| 16 | +| **Environment** | Local machine | Decentralized network on Sepolia | |
| 17 | +| **Fees** | Free (test accounts prefunded) | Sponsored FPC available | |
| 18 | +| **Block times** | Instant | ~36 seconds | |
| 19 | +| **Proving** | Optional | Required | |
| 20 | +| **Accounts** | Test accounts pre-deployed | Must create and deploy your own | |
| 21 | + |
| 22 | +:::info |
| 23 | +If you want to develop and iterate quickly, start with the [local network guide](./getting_started_on_local_network.md). The local network has instant blocks and no proving, making it faster for development. |
| 24 | +::: |
| 25 | + |
| 26 | +## Prerequisites |
| 27 | + |
| 28 | +- <General.node_ver /> |
| 29 | + |
| 30 | +## Install the Aztec toolchain |
| 31 | + |
| 32 | +Install the testnet version of the Aztec CLI: |
| 33 | + |
| 34 | +```bash |
| 35 | +VERSION=#include_testnet_version bash -i <(curl -sL https://install.aztec.network/#include_testnet_version) |
| 36 | +``` |
| 37 | + |
| 38 | +:::warning |
| 39 | +Testnet is version-dependent. It is currently running version `#include_testnet_version`. Maintain version consistency when interacting with the testnet to avoid errors. |
| 40 | +::: |
| 41 | + |
| 42 | +This installs: |
| 43 | + |
| 44 | +- **aztec** - Compiles and tests Aztec contracts, launches infrastructure, and provides utility commands |
| 45 | +- **aztec-up** - Version manager for the Aztec toolchain (`aztec-up install`, `aztec-up use`, `aztec-up list`) |
| 46 | +- **aztec-wallet** - CLI tool for interacting with the Aztec network |
| 47 | + |
| 48 | +## Getting started on testnet |
| 49 | + |
| 50 | +### Step 1: Set up your environment |
| 51 | + |
| 52 | +Set the required environment variables: |
| 53 | + |
| 54 | +```bash |
| 55 | +export NODE_URL=https://rpc.testnet.aztec-labs.com |
| 56 | +export SPONSORED_FPC_ADDRESS=0x2ae02a54fd254586fd628ff46b71071bd8db32b63dc5d083f844f2c208a3923c |
| 57 | +``` |
| 58 | + |
| 59 | +### Step 2: Register the Sponsored FPC |
| 60 | + |
| 61 | +The Sponsored FPC (Fee Payment Contract) pays transaction fees on your behalf, so you don't need to bridge Fee Juice from L1. Register it in your wallet: |
| 62 | + |
| 63 | +```bash |
| 64 | +aztec-wallet register-contract \ |
| 65 | + --node-url $NODE_URL \ |
| 66 | + --alias sponsoredfpc \ |
| 67 | + $SPONSORED_FPC_ADDRESS SponsoredFPC \ |
| 68 | + --salt 0 |
| 69 | +``` |
| 70 | + |
| 71 | +### Step 3: Create and deploy an account |
| 72 | + |
| 73 | +Unlike the local network, testnet has no pre-deployed accounts. Create and deploy your own: |
| 74 | + |
| 75 | +```bash |
| 76 | +aztec-wallet create-account \ |
| 77 | + --node-url $NODE_URL \ |
| 78 | + --alias my-wallet \ |
| 79 | + --payment method=fpc-sponsored,fpc=$SPONSORED_FPC_ADDRESS |
| 80 | +``` |
| 81 | + |
| 82 | +:::note |
| 83 | +The first transaction will take longer as it downloads proving keys. If you see `Timeout awaiting isMined`, the transaction is still processing — this is normal on testnet. |
| 84 | +::: |
| 85 | + |
| 86 | +### Step 4: Deploy a contract |
| 87 | + |
| 88 | +Deploy a token contract as an example: |
| 89 | + |
| 90 | +```bash |
| 91 | +aztec-wallet deploy \ |
| 92 | + --node-url $NODE_URL \ |
| 93 | + --from accounts:my-wallet \ |
| 94 | + --payment method=fpc-sponsored,fpc=$SPONSORED_FPC_ADDRESS \ |
| 95 | + --alias token \ |
| 96 | + TokenContract \ |
| 97 | + --args accounts:my-wallet Token TOK 18 |
| 98 | +``` |
| 99 | + |
| 100 | +This deploys the `TokenContract` with: |
| 101 | +- `admin`: your wallet address |
| 102 | +- `name`: Token |
| 103 | +- `symbol`: TOK |
| 104 | +- `decimals`: 18 |
| 105 | + |
| 106 | +You can check the transaction status on [Aztecscan](https://testnet.aztecscan.xyz). |
| 107 | + |
| 108 | +### Step 5: Interact with your contract |
| 109 | + |
| 110 | +Mint some tokens: |
| 111 | + |
| 112 | +```bash |
| 113 | +aztec-wallet send mint_to_public \ |
| 114 | + --node-url $NODE_URL \ |
| 115 | + --from accounts:my-wallet \ |
| 116 | + --payment method=fpc-sponsored,fpc=$SPONSORED_FPC_ADDRESS \ |
| 117 | + --contract-address token \ |
| 118 | + --args accounts:my-wallet 100 |
| 119 | +``` |
| 120 | + |
| 121 | +Check your balance: |
| 122 | + |
| 123 | +```bash |
| 124 | +aztec-wallet simulate balance_of_public \ |
| 125 | + --node-url $NODE_URL \ |
| 126 | + --from accounts:my-wallet \ |
| 127 | + --contract-address token \ |
| 128 | + --args accounts:my-wallet |
| 129 | +``` |
| 130 | + |
| 131 | +This should print: |
| 132 | + |
| 133 | +``` |
| 134 | +Simulation result: 100n |
| 135 | +``` |
| 136 | + |
| 137 | +Move tokens to private state: |
| 138 | + |
| 139 | +```bash |
| 140 | +aztec-wallet send transfer_to_private \ |
| 141 | + --node-url $NODE_URL \ |
| 142 | + --from accounts:my-wallet \ |
| 143 | + --payment method=fpc-sponsored,fpc=$SPONSORED_FPC_ADDRESS \ |
| 144 | + --contract-address token \ |
| 145 | + --args accounts:my-wallet 25 |
| 146 | +``` |
| 147 | + |
| 148 | +Check your private balance: |
| 149 | + |
| 150 | +```bash |
| 151 | +aztec-wallet simulate balance_of_private \ |
| 152 | + --node-url $NODE_URL \ |
| 153 | + --from accounts:my-wallet \ |
| 154 | + --contract-address token \ |
| 155 | + --args accounts:my-wallet |
| 156 | +``` |
| 157 | + |
| 158 | +This should print: |
| 159 | + |
| 160 | +``` |
| 161 | +Simulation result: 25n |
| 162 | +``` |
| 163 | + |
| 164 | +## Viewing transactions on the block explorer |
| 165 | + |
| 166 | +You can view your transactions, contracts, and account on the testnet block explorers: |
| 167 | + |
| 168 | +- [Aztecscan](https://testnet.aztecscan.xyz) |
| 169 | +- [Aztec Explorer](https://aztecexplorer.xyz/?network=testnet) |
| 170 | + |
| 171 | +Search by transaction hash, contract address, or account address to see details and status. |
| 172 | + |
| 173 | +## Registering existing contracts |
| 174 | + |
| 175 | +To interact with a contract deployed by someone else, you need to register it in your local PXE first: |
| 176 | + |
| 177 | +```bash |
| 178 | +aztec-wallet register-contract \ |
| 179 | + --node-url $NODE_URL \ |
| 180 | + --alias mycontract \ |
| 181 | + <CONTRACT_ADDRESS> <ArtifactName> |
| 182 | +``` |
| 183 | + |
| 184 | +For example, to register a `TokenContract` deployed by someone else: |
| 185 | + |
| 186 | +```bash |
| 187 | +aztec-wallet register-contract \ |
| 188 | + --node-url $NODE_URL \ |
| 189 | + --alias external-token \ |
| 190 | + 0x1234...abcd TokenContract |
| 191 | +``` |
| 192 | + |
| 193 | +After registration, you can interact with it using `aztec-wallet send` and `aztec-wallet simulate` as shown above. |
| 194 | + |
| 195 | +## Paying fees without the Sponsored FPC |
| 196 | + |
| 197 | +The Sponsored FPC is convenient for getting started, but you can also pay fees directly by bridging Fee Juice from Ethereum Sepolia. See [Paying Fees](./docs/aztec-js/how_to_pay_fees.md#bridge-fee-juice-from-l1) for details on bridging and other fee payment methods. |
| 198 | + |
| 199 | +## Testnet information |
| 200 | + |
| 201 | +For complete testnet technical details including contract addresses and network configuration, see the [Networks page](/networks#testnet). |
| 202 | + |
| 203 | +## Next steps |
| 204 | + |
| 205 | +- Check out the [Tutorials](./docs/tutorials/contract_tutorials/counter_contract.md) for building more complex contracts |
| 206 | +- Learn about [paying fees](./docs/aztec-js/how_to_pay_fees.md) with different methods |
| 207 | +- Explore [Aztec Playground](https://play.aztec.network/) for an interactive development experience |
0 commit comments