Prerequisites
Required Tools
Clone and Setup
Local Environment Setup
Start Local Chain
Start a local Ethereum node using Anvil (part of Foundry):- Available accounts with private keys
- Chain ID
- RPC endpoint (default:
http://127.0.0.1:8545)
Configure Environment
Create a.env file for local deployment:
.env
Deployment Methods
Method 1: Direct Forge Script
Deploy using Foundry’s forge script directly:Method 2: Using Deployment Script
For multi-chain local testing (e.g., two Anvil instances):Method 3: Minimal Portal-Only Deployment
Deploy only the Portal contract for basic testing:Verify Deployment
Check Deployed Contracts
After deployment, verify the contracts were deployed:Interact with Deployed Contracts
Use cast to interact with deployed contracts:Testing Against Local Deployment
Run Integration Tests
Run tests against the deployed contracts:Manual Testing Workflow
Development Workflow
Iterative Development
For rapid development iteration:Reset Local State
To start fresh:Common Issues
Port Already in Use
If port 8545 is already in use:Nonce Too High Error
If you get nonce errors after restarting Anvil:- This happens because Anvil resets but your deployment script remembers the old nonce
- Restart Anvil to reset the blockchain state
- Or use
--resetflag when running forge script
Gas Estimation Failed
If deployment fails with gas estimation errors:Next Steps
Run Tests
Run the test suite against your local deployment
Testnet Deployment
Deploy to public testnets after local testing