Foundry

Foundry is a blazing-fast, portable, and modular toolkit for Ethereum application development. This guide shows you how to deploy smart contracts to LitVM using Foundry.

Prerequisites

  • A wallet with testnet zkLTC (see Add to Your Wallet)

  • Basic familiarity with Solidity


Install Foundry

If you haven't installed Foundry yet:

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

# Install Foundry
foundryup

Verify installation:

forge --version

Create a New Project

This creates a project structure:


Write Your Contract

Create a simple contract in src/Counter.sol:


Configure for LitVM

Update foundry.toml to include LitVM network:


Set Up Environment

Create a .env file (add to .gitignore!):

Load environment variables:


Compile

Expected output:


Test

Run tests before deploying:

Add a test in test/Counter.t.sol:

Run with verbosity:


Deploy

1

Direct deploy

Use forge create with your RPC and private key:

2

Create script/Deploy.s.sol:

Run the script:


Verify Contract

Verify on LitVM Explorer:


Interact with Contract

Using cast

Using Forge Script

Create script/Interact.s.sol:


Gas Estimation

Check gas costs before deploying:


Common Issues

"Insufficient funds"

Ensure your wallet has testnet zkLTC. Visit the faucet.

"Nonce too low"

Reset nonce or wait for pending transactions to confirm:

"RPC error"
  • Check RPC URL is correct

  • Verify network connectivity

  • Try alternative RPC endpoints


Next Steps

  • Deploy more complex contracts (ERC-20, ERC-721, etc.)

  • Set up Hardhat for alternative tooling

  • Explore LitVM ecosystem dApps


Resources

Last updated