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.
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.
import { ethers } from "hardhat";
async function main() {
const token = await ethers.deployContract('Token', { gasLimit: 1000000 });
await token.waitForDeployment();
console.log(`Token contract deployed at ${token.target}`);
}
// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
npx hardhat run scripts/deploy.ts --network lumio-testnet