Deploy on EVM (Hardhat)
Create a wallet using Metamask (see how to configure) and request funds from the faucet for your new account.
Once your account is funded, download Node.js:
Nodejs v18+ required
Create a project
Let's create a project with Hardhat. Create a new folder and run the following command inside:
The command will initialize a new npm
project and install Hardhat locally.
Initialize a new Hardhat project
Select TypeScript
as the project type, and for the rest of the questions, such as .gitignore and sample project, choose y
or yes
Configure Hardhat with Lumio
Open the hardhat.config.ts
file generated by the previous command, and replace its content with the following:
Install toolbox
To install hardhat-toolbox
, run the following command:
Install dotenv
To install the dotenv
dependency, use the following command:
Once the dependency is installed, let's create a new file named .env
and place the private key inside it:
See how to export your private key from Metamask.
ERC20 Contract
Let's deploy an ERC-20 contract on the testnet. First, navigate to the contracts/
folder and remove the Lock.sol
file from the sample project as it is not needed.
Now, let's install the OpenZeppelin framework:
Create a new file in the contracts/
directory and name it Token.sol
. Then, put the following code inside:
Let's compile the code by running the following command:
After successful compilation, let's deploy the contract. Open the scripts/deploy.ts
file and replace its contents with the following code:
Important: Reth L2 doesn't support the "block tag pending." So, in case you encounter issues with block tags while using Hardhat, try adding the parameter blockTag: "latest"
. This may be particularly relevant, especially when estimating gas.
For deploy run the following command:
Awesome, after deployment you would see message:
Copy the address and go to block explorer, that's all! Now you can continue develop your contract/project on the EVM part of the L2.
Last updated