Deployment with Foundry

Walkthrough on deploying a sample smart contract with Foundry CLI.

Example Contract

USDC.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.19;

import "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol";

contract USDC is ERC20PresetMinterPauser {
    constructor() ERC20PresetMinterPauser("USD Coin", "USDC") {
        _mint(msg.sender, 20_000e6);
    }

    function decimals() public view virtual override returns (uint8) {
        return 6;
    }
}

Deployment Steps

Prepare a .env file containing all relevant chain information and deployment wallet address

FOUNDRY_PROFILE=claim
FOUNDRY_PK=<YOUR_PRIVATE_KEY>
FOUNDRY_OWNER_ADDRESS=<YOUR_ADDRESS>
RPC_URL_MANTRA_ETH=https://evm.dukong.mantrachain.io

Source the env file and compile the solidity contract

source .env && forge create --out FinanceClaim/src/foundry_artifacts/USDC.sol/ --rpc-url $RPC_URL_MANTRA_ETH --private-key $FOUNDRY_PK FinanceClaim/src/mock/USDC.sol:USDC

Last updated