Deploy a Contract
Prompt mode
Paste this into your coding agent:
Reference https://docs.taiko.xyz/SKILL.md
Write a minimal Counter contract at src/Counter.sol, then deploy and verify
it on Taiko mainnet. Use FOUNDRY_PROFILE=taiko to target Shanghai EVM and
verify via the Etherscan V2 endpoint:
https://api.etherscan.io/v2/api?chainid=167000Manual mode
Prerequisites
- Foundry installed
- ETH on Taiko (bridge from L1 or use a Hoodi faucet — see Bridge Tokens)
- An Etherscan API key — the V2 unified key verifies on Taikoscan too
Scaffold a project
forge init hello-taiko && cd hello-taikoforge init generates src/Counter.sol — a minimal contract we'll deploy below. If an agent is driving the flow, have it write a contract into src/ and use that filename instead.
Configure Foundry
Add a Taiko profile to foundry.toml:
[profile.taiko]
evm_version = "shanghai"Build with it:
FOUNDRY_PROFILE=taiko forge buildDeploy and verify
FOUNDRY_PROFILE=taiko forge create src/Counter.sol:Counter \
--rpc-url https://rpc.mainnet.taiko.xyz \
--private-key $PRIVATE_KEY \
--broadcast \
--verify \
--verifier etherscan \
--verifier-url 'https://api.etherscan.io/v2/api?chainid=167000' \
--etherscan-api-key $ETHERSCAN_API_KEY--broadcast is required — without it, forge create only simulates.
Confirm deployment
cast code $DEPLOYED_ADDRESS --rpc-url https://rpc.mainnet.taiko.xyzA non-empty hex response confirms the contract exists on-chain.
Verify an already-deployed contract
Same V2 URL, with forge verify-contract:
FOUNDRY_PROFILE=taiko forge verify-contract $CONTRACT_ADDRESS \
src/Counter.sol:Counter \
--verifier etherscan \
--verifier-url 'https://api.etherscan.io/v2/api?chainid=167000' \
--etherscan-api-key $ETHERSCAN_API_KEY \
--watchSwap chainid=167000 → chainid=167013 for Hoodi. --watch blocks until Taikoscan returns a final status.
If your constructor takes arguments, pass them with --constructor-args using the same values you deployed with. Encode complex types first: cast abi-encode "constructor(address,uint256)" 0xYourAddress 1000000000000000000.
Troubleshooting
| Problem | Cause | Fix |
|---|---|---|
forge create prints ABI but nothing deploys | Missing --broadcast | Add --broadcast to the command |
| Deployment reverts with no error | Wrong EVM version | Set evm_version = "shanghai" in foundry.toml and rebuild |
EvmError: NotActivated | Cancun opcode on Shanghai | Same as above — rebuild with FOUNDRY_PROFILE=taiko |
insufficient funds | Not enough ETH on Taiko | Bridge ETH from L1 or use the Hoodi faucet |
deprecated V1 endpoint | Using api.taikoscan.io/api | Switch to https://api.etherscan.io/v2/api?chainid=167000 |
NOTOK: Unable to verify | EVM version mismatch | Recompile with evm_version = "shanghai" and redeploy |
NOTOK: Already Verified | Contract is already verified | No action needed — check the explorer |
| Bytecode mismatch | Compiler version differs | Use the exact solc version from your build (check with forge config) |
| Missing constructor args | Args not provided or mis-encoded | Pass --constructor-args with the same values used at deploy time |
Invalid API Key | Key not set or wrong key | Get an Etherscan API key — the V2 key works for all chains |