Prerequisites
Foundry
For this tutorial, we will be using Foundry toolkit to develop, compile, and deploy our contracts. If you do not have Foundry installed, follow the Foundry installation instructions.Setup
First, we need to create a new directory for our project.Implementing the Contract
Before writing our contract, we first need to rename the template contract toNewInitiaERC20.sol
InitiaERC20 contract from the
initia-evm-contracts
package.
src/NewInitiaERC20.sol
InitiaERC20 contract and add the constructor to
initialize the contract with the name, symbol, and decimals of our custom ERC20.
For this tutorial, we will simply customize the base contract by adding a logic
to mint tokens to the contract deployer during deployment.
src/NewInitiaERC20.sol
forge compile, we will get an error.
This is because the default Counter.t.sol and Counter.s.sol expect the
original Counter.sol contract to be available. To fix this, we will rename
Counter.t.sol to NewInitiaERC20.t.sol and Counter.s.sol to
NewInitiaERC20.s.sol.
NewInitiaERC20.t.sol file with the
following placeholder content.
test/NewInitiaERC20.t.sol
NewInitiaERC20.s.sol file with the following
placeholder content.
script/NewInitiaERC20.s.sol
forge compile should work without any errors.
Expected Output:
Deploying the Contract
Now that our contract is compiled and ready, we can deploy it to the MiniEVM. To accomplish this, we will use Foundry’sforge create command.
Expected Output:
cast call command.