Deploy a contract
This guide will help you deploy a smart contract on Taiko.
Prerequisites
- A wallet with some testnet ETH on Taiko (can receive this from the bridge).
- The private key to the account with testnet ETH on Taiko.
Mainnet
Deploy a contract using Foundry
-
Install Foundry
Open a terminal and run the following commands to install Foundry:
-
Create a project with Foundry
-
Deploy your contract
Deploy the contract located at
src/Counter.sol
. ReplaceYOUR_PRIVATE_KEY
below with your private key which has some testnet ETH on Taiko.
Deploy a contract using Hardhat
Hardhat is an Ethereum development environment for deploying smart contracts, running tests, and debugging Solidity code locally. It is one of the popular smart contract development frameworks. This guide demonstrates deploying a Storage smart contract
on Taiko using Hardhat, highlighting the compatibility of Ethereum contracts with Taiko.
-
Set up the environment Hardhat is a flexible Ethereum development environment designed for testing, compiling, and deploying smart contracts. It requires Node.js, npm, and Git to get started.
To effectively use Hardhat, your system must have Node.js (v10+ LTS) and npm installed.
-
Create a Hardhat project
- In your desired directory, run
- Initialize an npm project
- Install dotenv for environment variable management
- Add Hardhat to your project
- Initialize Hardhat
Choose
Create a JavaScript project
and follow the prompts, agreeing to create a.gitignore
and install suggested dependencies. -
Configure Your Project
- Delete
Lock.sol
in the/contracts
directory. - In your project’s
/contracts
directory, create a new file namedStorage.sol
and paste the provided Solidity code into it using your text editor.
This contract, named
Storage
, includes functions to store and retrieve auint256
number.- Create the
/scripts
to write a deployment script. Then create and open a newdeploy.js
file to insert the provided JavaScript code. - Proceed to the
/scripts
directory of your Hardhat project to write a deployment script. Then create and open a newdeploy.js
file to insert the provided JavaScript code.
-
Populate the
.env
file. That is,- Create a
.env
file within theroot
folder. - Populate
.env
with yourYOUR_PRIVATE_KEY
and the Taiko’sRPC_URL
as follows:
- Create a
- Update
hardhat.config.js
with the following configuration to include Taiko network settings and Solidity version.
- Delete
-
Compile your contracts To compile your smart contracts, run
Your compiled contracts will be located in the
artifacts/
directory. -
Deploy your contracts To deploy your contracts to Taiko network, use
This command deploys your
Storage
contract to the Taiko. For additional details on deploying contracts with Hardhat, refer to the Deploying Contracts with Hardhat. The output on the terminal looks like as below.You can now check your deployed contract on any explorer found on our homepage using the
deployed contract address
.
Deploy a contract using thirdweb
Thirdweb offers a streamlined solution for deploying smart contracts to any EVM-compatible chain, including Taiko. By simplifying the deployment process, Thirdweb enables developers to focus on building without the hassle of managing private keys, RPC URLs, or deployment scripts. This guide demonstrates deploying a Lock smart contract
on Taiko using Thirdweb, highlighting the compatibility of Ethereum contracts with Taiko.
-
Set up the environment
Before deploying a smart contract on Taiko with Thirdweb, ensure your contracts are ready in a folder or a Hardhat project. This setup can include a Hardhat project or any other structure where your contracts are organized.
For setup details, see our Hardhat Deployment guide on taiko.
-
Deploying with Thirdweb
-
Initialize Your Project
Navigate to your smart contract project’s root directory in the CLI and install Thirdweb globally using
npm i -g thirdweb
. -
Deploy Your Contract
Execute
thirdweb deploy
in the CLI. This command initiates the deployment process. -
Authorize Your Device
A browser window will prompt you to connect and authorize your wallet. This step ensures secure deployment from your chosen wallet.
-
Access the Deployment Link
The CLI will provide a link. Open this link to proceed with deployment via the Thirdweb UI.
-
Complete Deployment Details
- Fill in the necessary fields in the Thirdweb UI.
- Select
Taiko Network
from the Chain drop-down menu. - Opt for
Add to dashboard
if you wish to manage this contract from the Thirdweb dashboard. - Click
Deploy Now
and sign the transaction in your connected wallet.
For a more detailed documentation on deployments through Thirdweb using CLI, visit Thirdweb CLI Docs.
-
-
Managing Your Contract
After deployment, the Thirdweb dashboard allows you to manage and interact with your contract seamlessly. Deploying with Thirdweb not only streamlines the process but also enhances security by supporting browser-based wallets like MetaMask and others for deployment activities.
Hekla
Deploy a contract using Foundry
-
Install Foundry
Open a terminal and run the following commands to install Foundry:
-
Create a project with Foundry
-
Deploy your contract
Deploy the contract located at
src/Counter.sol
. ReplaceYOUR_PRIVATE_KEY
below with your private key which has some testnet ETH on Taiko.
Deploy a contract using Hardhat
Hardhat is an Ethereum development environment for deploying smart contracts, running tests, and debugging Solidity code locally. It is one of the popular smart contract development frameworks. This guide demonstrates deploying a Storage smart contract
on Taiko using Hardhat, highlighting the compatibility of Ethereum contracts with Taiko.
-
Set up the environment Hardhat is a flexible Ethereum development environment designed for testing, compiling, and deploying smart contracts. It requires Node.js, npm, and Git to get started.
To effectively use Hardhat, your system must have Node.js (v10+ LTS) and npm installed.
-
Create a Hardhat project
- In your desired directory, run
- Initialize an npm project
- Install dotenv for environment variable management
- Add Hardhat to your project
- Initialize Hardhat
Choose
Create a JavaScript project
and follow the prompts, agreeing to create a.gitignore
and install suggested dependencies. -
Configure Your Project
- Delete
Lock.sol
in the/contracts
directory. - In your project’s
/contracts
directory, create a new file namedStorage.sol
and paste the provided Solidity code into it using your text editor.
This contract, named
Storage
, includes functions to store and retrieve auint256
number.- Create the
/scripts
to write a deployment script. Then create and open a newdeploy.js
file to insert the provided JavaScript code. - Proceed to the
/scripts
directory of your Hardhat project to write a deployment script. Then create and open a newdeploy.js
file to insert the provided JavaScript code.
-
Populate the
.env
file. That is,- Create a
.env
file within theroot
folder. - Populate
.env
with yourYOUR_PRIVATE_KEY
and the Taiko’sRPC_URL
as follows:
- Create a
- Update
hardhat.config.js
with the following configuration to include Taiko network settings and Solidity version.
- Delete
-
Compile your contracts To compile your smart contracts, run
Your compiled contracts will be located in the
artifacts/
directory. -
Deploy your contracts To deploy your contracts to Taiko network, use
This command deploys your
Storage
contract to the Taiko. For additional details on deploying contracts with Hardhat, refer to the Deploying Contracts with Hardhat. The output on the terminal looks like as below.You can now check your deployed contract on the explorer using the
deployed contract address
.
Deploy a contract using Remix
-
Open Remix IDE
Visit Remix IDE.
-
Create a new
.sol
file- Give it any name, for example
Counter.sol
. - Fill with this example code:
- Give it any name, for example
-
Compile
- Change the Compiler version to
0.7.0+commit.9e61f92b
- Then compile it.
- Change the Compiler version to
-
Deploy
- Change the Environment to
Injected Provider
-
Then click
transact
-
Finally, verify the smart contract using Blockscout
- Change the Environment to
Deploy a contract using thirdweb
Thirdweb offers a streamlined solution for deploying smart contracts to any EVM-compatible chain, including Taiko. By simplifying the deployment process, Thirdweb enables developers to focus on building without the hassle of managing private keys, RPC URLs, or deployment scripts. This guide demonstrates deploying a Lock smart contract
on Taiko using Thirdweb, highlighting the compatibility of Ethereum contracts with Taiko.
-
Set up the environment
Before deploying a smart contract on Taiko with Thirdweb, ensure your contracts are ready in a folder or a Hardhat project. This setup can include a Hardhat project or any other structure where your contracts are organized.
For setup details, see our Hardhat Deployment guide on taiko.
-
Deploying with Thirdweb
-
Initialize Your Project
Navigate to your smart contract project’s root directory in the CLI and install Thirdweb globally using
npm i -g thirdweb
. -
Deploy Your Contract
Execute
thirdweb deploy
in the CLI. This command initiates the deployment process. -
Authorize Your Device
A browser window will prompt you to connect and authorize your wallet. This step ensures secure deployment from your chosen wallet.
-
Access the Deployment Link
The CLI will provide a link. Open this link to proceed with deployment via the Thirdweb UI.
-
Complete Deployment Details
- Fill in the necessary fields in the Thirdweb UI.
- Select
Taiko Network
from the Chain drop-down menu. - Opt for
Add to dashboard
if you wish to manage this contract from the Thirdweb dashboard. - Click
Deploy Now
and sign the transaction in your connected wallet.
For a more detailed documentation on deployments through Thirdweb using CLI, visit Thirdweb CLI Docs.
-
-
Managing Your Contract
After deployment, the Thirdweb dashboard allows you to manage and interact with your contract seamlessly. Deploying with Thirdweb not only streamlines the process but also enhances security by supporting browser-based wallets like MetaMask and others for deployment activities.