4. Deploying the contract
This guide walks you through deploying your Confidential ERC20 smart contract on the Sepolia test network.
Prerequisites
Before proceeding, ensure you have:
A configured Hardhat project using the fhEVM Hardhat Template (see previous sections).
A crypto wallet installed (e.g., Metamask).
Some Sepolia ETH available for testing. If you don’t have enough ETH, use a Sepolia faucet to request free SepoliaETH for testing:
Step 1. Preparing for deployment
Generate a mnemonic seed for accounts using
cast
:(
cast
is a Foundry function. If you don't have Foundry installed, runcurl -L https://foundry.paradigm.xyz | bash
first):
Obtain a Sepolia RPC URL:
Sign up for a node provider such as Alchemy -
https://www.alchemy.com/
or Infura -https://infura.io/
. Copy your Sepolia RPC URL.
Open the
.env
file:Past your mnemonic in the code:
MNEMONIC=
<Your mnemonic generated>
Paste a Sepolia RPC URL:
SEPOLIA_RPC_URL=
<Your node provider URL>
Verify generated accounts:
Step 2. Funding your wallet
Open your wallet (e.g, MetaMask)
Import the first 2 accounts (e.g., Alice and Bob) into your wallet with their private keys.
Fund these 2 accounts with some Sepolia ETH.
Step 3. Deploying the contract
In the deploy/
directory, there is a preconfigured deploy.ts
file that handles the deployment process. You can customize it or add your own scripts.
To deploy the contracts to Sepolia, run:
Step 4. Verify the deployment
Once deployment is successful, you should see a console output that includes the contract address such as:
You can verify this contract on Sepolia Etherscan by searching for the deployed address.
Congratulations! 🎉 You have deployed your first confidential ERC20 smart contract. Let's mint a few tokens and perform some encrypted transactions!
Last updated
Was this helpful?