Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Deploy a Contract

Deploy and verify smart contracts on Taiko using Foundry.

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=167000

Manual mode

Prerequisites

Scaffold a project

forge init hello-taiko && cd hello-taiko

forge 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 build

Deploy and verify

Mainnet
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.xyz

A 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 \
  --watch

Swap chainid=167000chainid=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

ProblemCauseFix
forge create prints ABI but nothing deploysMissing --broadcastAdd --broadcast to the command
Deployment reverts with no errorWrong EVM versionSet evm_version = "shanghai" in foundry.toml and rebuild
EvmError: NotActivatedCancun opcode on ShanghaiSame as above — rebuild with FOUNDRY_PROFILE=taiko
insufficient fundsNot enough ETH on TaikoBridge ETH from L1 or use the Hoodi faucet
deprecated V1 endpointUsing api.taikoscan.io/apiSwitch to https://api.etherscan.io/v2/api?chainid=167000
NOTOK: Unable to verifyEVM version mismatchRecompile with evm_version = "shanghai" and redeploy
NOTOK: Already VerifiedContract is already verifiedNo action needed — check the explorer
Bytecode mismatchCompiler version differsUse the exact solc version from your build (check with forge config)
Missing constructor argsArgs not provided or mis-encodedPass --constructor-args with the same values used at deploy time
Invalid API KeyKey not set or wrong keyGet an Etherscan API key — the V2 key works for all chains