Deploy FHECounter to Sepolia
Guide for deploying the FHECounter contract to Sepolia testnet.
Get Sepolia ETH: You need testnet ETH to deploy. Get it from faucets:
Export Private Key from MetaMask:
Click the three dots menu → Account Details
Enter your password and copy the key
Create a .env file in the root directory with your deployer private key:
# Required: Your deployer wallet private key (must have Sepolia ETH)
DEPLOYER_PRIVATE_KEY=0x1234567890abcdef...
# Optional: Custom Sepolia RPC (defaults to https://ethereum-sepolia-rpc.publicnode.com)
SEPOLIA_RPC_URL=https://rpc.sepolia.org
⚠️ Security Warning
Never commit .env files or expose your private key. The .env file is already in .gitignore.
Check your deployer address and balance before deploying:
This will show your deployer address and current Sepolia ETH balance. Make sure you have enough ETH before proceeding.
From the root directory, run:
The script will:
Connect to Sepolia network
Deploy the FHECounter contract
Output the deployed contract address
After Deployment
Save the contract address from the output
Update your examples to use the new address:
For Next.js: Set NEXT_PUBLIC_SEPOLIA_COUNTER_ADDRESS in examples/nextjs/.env.local
For Vue: Set VITE_SEPOLIA_COUNTER_ADDRESS in examples/vue/.env.local
For Node.js: Set SEPOLIA_COUNTER_ADDRESS in examples/nodejs/.env
Verify on Etherscan (optional):
Troubleshooting
"Insufficient funds"
You don't have enough Sepolia ETH. Get more from faucets listed above.
"Invalid private key"
Ensure your DEPLOYER_PRIVATE_KEY in .env starts with 0x and is 66 characters long.
"Network not found"
Make sure you're running the command from the root directory where .env is located.
Custom RPC Issues
If deployment fails, try using a different RPC URL in SEPOLIA_RPC_URL. Public RPCs:
https://ethereum-sepolia-rpc.publicnode.com
https://eth-sepolia.public.blastapi.io
Last updated