Project Setup
First, create a new project directory:src: For your script files.abis: For your contract ABIs.
abis directory:
Setting Up Environment Variables
Create a.env file in your project root:
ERC20Factory contract is automatically deployed on all MiniEVM rollups as
part of the chain’s bootstrapping process.
To retrieve the deployed factory address, query
{ROLLUP_REST_URL}/minievm/evm/v1/contracts/erc20_factory.
{ROLLUP_REST_URL} refers to the REST endpoint of the rollup you are
interacting with.
Example:
.env file as ERC20_FACTORY_ADDRESS.
Next, export an EVM-compatible private key from your Ethereum wallet. This
private key will be used to sign and send transactions to the MiniEVM.
Your .env file should look like this:
Development
Creating the Chain Configuration File
To interact with the MiniEVM using Viem, you need a chain configuration file. This file contains essential details about the chain, including the chain ID, name, native currency, and RPC URLs. Create achain.js file in the src directory:
Interacting with the ERC20Factory Contract
Next, create a script to interact with the ERC20Factory contract:You can also find factory addresses on the
Networks page or by calling the
/minievm/evm/v1/contracts/erc20_factory endpoint on any MiniEVM rollup.createERC20 method of the
ERC20Factory contract.
Implement the createERC20 function: