Foundry
The FEVM Foundry Kit is a Foundry template for Filecoin EVM projects. It includes Solidity examples, Filecoin API examples, Foundry remappings, and verification tooling for Filecoin explorers.
Prerequisites
You must have the following installed:
You should also have an address on the Filecoin Calibration testnet. See the MetaMask setup page for information on how to get an address. You also need test tFIL in your wallet.
Steps
- Clone the
filecoin-project/fevm-foundry-kitrepository and move into thefevm-foundry-kitdirectory:
git clone https://github.com/filecoin-project/fevm-foundry-kit
cd fevm-foundry-kit
- Build the contracts and install the project’s npm dependencies:
forge build
npm install
Export your private key from MetaMask. See the MetaMask documentation to find out how to export your private key.
Create your env file by running:
cp .env.example .env
- In your newly created
.env, replacePRIVATE_KEYwith the private key exported from MetaMask. Keep the Calibration RPC URL or replace it with your preferred Filecoin Calibration RPC endpoint:
PRIVATE_KEY=your_private_key_here
CALIBRATIONNET_RPC_URL=https://api.calibration.node.glif.io/rpc/v1
- Load the variables in your current shell before running deployment commands:
source .env
Never commit .env files or real private keys. Anyone with access to the private key can spend funds from the account.
- Deploy the kit’s
DealClientexample contract to Calibration:
forge create \
--rpc-url "$CALIBRATIONNET_RPC_URL" \
--private-key "$PRIVATE_KEY" \
--broadcast \
src/basic-deal-client/DealClient.sol:DealClient
The deployment output is environment-dependent. Record the Deployed to address from Foundry’s output; you will need it for contract interactions and verification.
- You can now interact with your contract using the contract address given by Foundry.
Done! For more information, see the Foundry book.