Docs
  • FlexNet
  • Build on FlexNet
    • Network Information
    • FlexLabs Incubator
    • Network Fees
  • Tools
    • Bridges
    • Block Explorers
    • Faucets
    • Wallets
  • Deploy Your App
    • Hardhat
    • Foundry
    • Remix
Powered by GitBook
On this page
  • Get Started with Foundry
  • Deploying Your Smart Contract
Export as PDF
  1. Deploy Your App

Foundry

PreviousHardhatNextRemix

Last updated 12 days ago

is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.

Foundry consists of:

: Ethereum testing framework (like Truffle, Hardhat and DappTools).

: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.

: Local Ethereum node, akin to Ganache, Hardhat Network.

: Fast, utilitarian, and verbose solidity REPL.​

Get Started with Foundry

  1. Install Foundry

  • Linux or MaxOS

curl -L https://foundry.paradigm.xyz | bash
foundryup

  • Windows

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs/ | sh
cargo install --git https://github.com/foundry-rs/foundry foundry-cli anvil --bins --locked

  1. Create a project

forge init foundry

  1. Navigate to the Source in the project and create your smart contract

cd src
touch MyToken.sol

  1. Input your smart contract or use the sample contract below.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
 
contract HelloWorld {
    string public greet = "Hello World!";
}

  1. Install OpenZeppelin contracts as a dependency

forge install OpenZeppelin/openzeppelin-contracts

  1. Compile contract

forge build

Deploying Your Smart Contract

Deploying a contract with Forge is a simple process that can be done with a single command. However, it requires an RPC endpoint, a private key that has funds, and any arguments for the constructor of the contract.

For example, the MyToken.sol contract requires an initial supply of tokens to be specified in its constructor, so the command to deploy it on a network will include the argument of 100.

To deploy the MyToken.sol contract, use the command that corresponds to the Mint chain’s RPC URL while running the forge create command:

Testnet

forge create --rpc-url "
https://rpc-testnet.flexnet.tech"
--constructor-args 100 \
--private-key YOUR_PRIVATE_KEY \
src/MyToken.sol:MyToken

Foundry
Forge
Cast
Anvil
Chisel