Skip to main content

Setup Foundry

Foundry is a blazing fast, portable, and modular toolkit for Ethereum application development written in Rust. This guide will help you set up Foundry for developing on SKALE.

Prerequisites

  • Rust installed on your machine
  • Basic command-line knowledge
If you are on a Windows machine, you will need to use Windows Subsystem for Linux (WSL), since Foundry doesn’t work natively on Windows.

Step 1: Install Foundry

Install Foundry by running:
This will install the latest stable release of Foundry, including:
  • Forge: Build, test, and deploy smart contracts
  • Cast: Interact with EVM smart contracts, send transactions, and read chain data
  • Anvil: Local Ethereum node for testing
  • Chisel: Solidity REPL

Step 2: Verify Installation

Verify that Foundry is installed correctly:
You should see version numbers for each tool.

Step 3: Create a New Foundry Project

Create a new Foundry project:
This creates a new directory with the following structure:

Step 4: Configure Foundry for SKALE

Update the foundry.toml file to add SKALE Chain endpoints:
Replace the RPC URLs with your specific SKALE Chain endpoint. You can find SKALE Chain endpoints in the SKALE Portal.

Step 5: Install Dependencies

Install OpenZeppelin Contracts (or other dependencies):
This will add the dependency to your lib directory. For secure deployment, create a Foundry keystore:
Provide a password to encrypt the keystore file. If you forget this password, you will not be able to recover it.
Get your wallet address:
Copy this address and fund it with sFUEL from the sFUEL Station.

Step 7: Test Your Setup

Compile your contracts:
Run tests:

SKALE-Specific Considerations

When deploying to SKALE, remember to:
  1. Use the --legacy flag: SKALE Chains require legacy transaction format
  2. Use --slow flag for scripts: When running scripts with multiple transactions
  3. Verify contracts: Use the block explorer API for verification