Beginner
Deploying a Contract on Testnet — Hands-on
End-to-end deploy experience.
Developer Beginner
5/7 — Deploying a Contract on Testnet — Hands-on
Record everythingSave the deployed address, chainId, block number, and ABI for later steps. These become inputs for frontends and tests.
Blockchains solve coordination problems, not just financial ones.
Steps
- Create a Hardhat project:
npm init -y && npx hardhat. Choose an empty config. - Write a tiny contract:(e.g., Counter.sol) in
contracts/. - Fund a fresh testnet:EOA (Sepolia or Goerli) via faucet; add its key + RPC URL to .env.
- Add the network to:Hardhat.config and run
npx hardhat run scripts/deploy.js --network sepolia(or your network). - Copy the deployed address;:Check the explorer for code and logs. Note gas used and the deployer address.
- Verify the contract using:The Hardhat verify task or the explorer’s verify UI. Ensure the ABI matches.
- Optional:Re-run the script with a higher nonce to see how the contract address changes if you send another deployment tx.