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.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

Deployment Steps

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

Source the env file and deploy the contract. Execute the command from the root of the project folder.

Last updated