Deploy a contract
These steps will show you how to deploy a smart contract to Taiko A1 using Foundry. Read the Foundry Book (opens in a new tab) for the latest docs on Foundry.
Prerequisites
-
Have the private key to an account that has some ETH on Taiko A1. This is to pay the small transaction fee for deploying the contract. You can check the following articles if you are unsure how to do this:
Steps
- Install Foundry (opens in a new tab) (if you haven't already).
- Create a project with Foundry, and
cd
into it:forge init hello_foundry && cd hello_foundry
- Deploy the contract from your project, located at
src/Counter.sol
. ReplaceYOUR_PRIVATE_KEY
with your private key, mentioned in the previous prerequisites section.forge create --legacy --rpc-url https://l2rpc.a1.taiko.xyz --private-key YOUR_PRIVATE_KEY src/Counter.sol:Counter
Note: The
--legacy
flag is needed because EIP-1559 is currently disabled on Taiko—there are plans to re-enable it in the future. - Paste the address from the output into the L2 block explorer (opens in a new tab) to verify that the contract was deployed.