Foundry
This is an example of deploying a contract using Foundry.
1. Create a Foundry project
Run the command below to initialize the Foundry project.
forge init erc20-project
cd erc20-project2. Write the contract code
Save the ERC20 contract as an ERC20.sol file inside the src folder.
3. Set up the environment
Set the CROSS Chain information and private key in the .env file.
CHAIN_ID=612044
RPC_URL="https://testnet.crosstoken.io:22001”
EXPLORER="https://testnet.crossscan.io”
explorer_api="https://testnet.crossscan.io/api”
PRIVATE_KEY="<Enter the private key of the account to distribute>”Load the .env file into environment variables.
source .env4. Compile the contract
Compile the contract with the following command.
forge build5. Deploy the contract
Deploy the ERC20 contract to the CROSS Chain testnet with the following command.
forge create \
--broadcast \
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY \
src/ERC20.sol:ERC20 \
--constructor-args “My ERC20” “M20” 18 1000000etherAfter the deployment is complete, the transaction hash and contract address will appear.
6. Verify the contract
To verify the contract deployed with Foundry on Testnet Explorer, run the following command.
forge verify-contract \
--rpc-url $RPC_URL \
--verifier blockscout \
--verifier-url $EXPLORER_API \
--constructor-args $(cast abi-encode “constructor(string,string,uint8,uint256)” “My ERC20” “M20” 18 1000000ether) \
<deployed contract address> src/ERC20.sol:ERC20Note: You can check the deployed contract in the CROSS Chain Testnet Explorer.
Updated about 2 months ago