Deployment with Foundry
Walkthrough on deploying a sample smart contract with Foundry CLI.
Example Contract
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import {Script, console} from "forge-std/Script.sol";
import {Counter} from "../src/Counter.sol";
contract CounterScript is Script {
Counter public counter;
function setUp() public {}
function run() public {
vm.startBroadcast();
counter = new Counter();
vm.stopBroadcast();
}
}
Comile the solidity contract
forge build
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 deploy the contract. Execute the command from the root of the project folder.
source .env && forge create --out src/Counter.sol:Counter --rpc-url $RPC_URL_MANTRA_ETH --private-key $FOUNDRY_PK src/Counter.sol:Counter
Last updated