| content | layout | showLogo | description | ||
|---|---|---|---|---|---|
|
landing |
false |
Foundry is a smart contract development toolchain. It manages your dependencies, compiles your project, runs tests, deploys, and lets you interact with the chain from the command-line and via Solidity scripts. |
import { HomePage, Sponsors } from "vocs/components";
```bash [foundryup]
# Download foundry installer `foundryup`
curl -L https://foundry.paradigm.xyz | bash
# Install forge, cast, anvil, chisel
foundryup
# Install the latest nightly release
foundryup -i nightly
```
stars
9K
contributors
500+
Fork Testing
Test your contracts against real world chain state
Ultra-fast compilation
Lower compilation times drastically using `dynamic_test_linking`
forge helps you build, test, debug, deploy and verify smart contracts.
:::code-group
# Initializes a project called `Counter`
forge init Counter# Run tests for the Counter contract
forge test
# You can run tests against chain state by forking
forge test --fork-url https://reth-ethereum.ithaca.xyz/rpc# Use forge scripts to deploy the Counter contract
# Running `anvil` @ http://localhost:8545
# Set the private key in the env
export PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" # Address - 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266
# Run the script and broadcast the deploy transaction
forge script script/Counter.s.sol --rpc-url http://127.0.0.1:8545 --broadcast --private-key $PRIVATE_KEY# Clones an onchain contract and sets up a forge project
forge clone 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2:::
anvil is your local development node that complies with the Ethereum JSON-RPC spec.
:::code-group
# Start a fresh anvil node with 10 pre-funded accounts
anvil# Fork latest mainnet state
anvil --fork-url https://reth-ethereum.ithaca.xyz/rpc# Load and dump state when initializing and shutting down anvil
anvil --state ./path/to/state-file:::
cast is your swiss army knife for interacting with onchain applications from the command line.
:::code-group
# Perform an `eth_call` on a contract to read balances
cast call 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 \
"balanceOf(address)" 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045 \
--rpc-url https://reth-ethereum.ithaca.xyz/rpc# Running `anvil` @ http://localhost:8545
# Set the private key in the env
export PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
# Send the transaction
cast send 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 --value 10000000 --private-key $PRIVATE_KEY && \
# Fetch ETH balances
echo "\nBalance Of 0x7099:" && cast balance 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 && \
echo "\nBalance Of 0xf39F:" && cast balance 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266# Calls the `eth_getHeaderByNumber` RPC method with the number param in hexadecimal
# cast 2h converts integer to hex
cast rpc eth_getHeaderByNumber $(cast 2h 22539851) --rpc-url https://reth-ethereum.ithaca.xyz/rpc:::
Join the Community
- Ask for support in the Telegram chat or create an issue on Github
- Join the 500+ developers by contributing to Foundry
