You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A high-performance local Ethereum development node simulator written in Go, designed specifically for StableNet blockchain testing and development. Fully compatible with Foundry and Hardhat toolchains.
Features
Core Capabilities
Fast Local Development: Instant transaction confirmation with auto-mining
Foundry Compatible: Full support for anvil_* cheat codes
Hardhat Compatible: Support for evm_* methods
StableNet Native: First-class support for WBFT consensus and system contracts
State Management
State Snapshots: Save and restore blockchain state instantly
State Dump/Load: Export and import full blockchain state
Account Impersonation: Send transactions as any address without private keys
Testing Features
Time Manipulation: Control block timestamps for testing time-dependent logic
Gas Price Control: Set custom gas prices and base fees
Transaction Pool: Full mempool simulation with pending transaction queries
Transaction Tracing: Debug traces for transaction execution analysis
Debug Tracing: Full debug_traceTransaction and debug_traceCall support
Installation
# Build from source
make build
# Install to GOPATH/bin
make install
Quick Start
# Start with default settings
anvil
# Start with custom port
anvil --port 8546
# Start with more test accounts
anvil --accounts 20
# Start with StableNet system contracts
anvil --stablenet
# Get chain ID
curl -X POST http://localhost:8545 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}'# Set balance for an address
curl -X POST http://localhost:8545 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"anvil_setBalance","params":["0x1234...","0xde0b6b3a7640000"],"id":1}'# Mine 10 blocks
curl -X POST http://localhost:8545 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"anvil_mine","params":["0xa"],"id":1}'# Take a snapshot
curl -X POST http://localhost:8545 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"anvil_snapshot","params":[],"id":1}'# Impersonate an account
curl -X POST http://localhost:8545 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"anvil_impersonateAccount","params":["0x1234..."],"id":1}'
Using with Foundry
# Start anvil-go
anvil
# In another terminal, use forge/cast
cast chain-id --rpc-url http://localhost:8545
cast balance 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --rpc-url http://localhost:8545
cast rpc anvil_setBalance 0x1234... 0xde0b6b3a7640000 --rpc-url http://localhost:8545
Using with ethers.js
const{ ethers }=require('ethers');constprovider=newethers.JsonRpcProvider('http://localhost:8545');// Get chain IDconstchainId=awaitprovider.getNetwork().then(n=>n.chainId);// Set balance using anvil cheat codeawaitprovider.send('anvil_setBalance',['0x1234567890123456789012345678901234567890','0xde0b6b3a7640000'// 1 ETH]);// Mine blocksawaitprovider.send('anvil_mine',['0xa']);// Mine 10 blocks// Snapshot and revertconstsnapshotId=awaitprovider.send('anvil_snapshot',[]);// ... do some transactions ...awaitprovider.send('anvil_revert',[snapshotId]);
Using with web3.py
fromweb3importWeb3w3=Web3(Web3.HTTPProvider('http://localhost:8545'))
# Get chain IDchain_id=w3.eth.chain_id# Set balancew3.provider.make_request('anvil_setBalance', [
'0x1234567890123456789012345678901234567890',
'0xde0b6b3a7640000'
])
# Mine blocksw3.provider.make_request('anvil_mine', ['0xa'])
# Snapshot and revertresult=w3.provider.make_request('anvil_snapshot', [])
snapshot_id=result['result']
# ... do some transactions ...w3.provider.make_request('anvil_revert', [snapshot_id])
Development
# Run tests
make test# Run tests with coverage
make test-coverage
# Run linter
make lint
# Format code
make fmt
# Build
make build
# Run benchmarks
go test ./test/benchmark/... -bench=. -benchmem
Documentation
Architecture - Design philosophy and component overview
Specification - Technical specification and API reference