This project provides a local Pulsechain fork using Foundry/Anvil for testing and development purposes. It creates a local blockchain that mirrors the state of Pulsechain mainnet, allowing you to test contracts and transactions without using real PLS tokens.
- Foundry installed
- Node.js (optional, for additional tooling)
-
Clone this repository (if not already done)
-
Install dependencies:
forge install
-
Copy the environment file:
cp env.example .env
Use the provided script to start a local Pulsechain fork:
./start-fork.shThis will start an Anvil instance that forks Pulsechain mainnet with the following configuration:
- Local RPC URL:
http://127.0.0.1:8545 - Chain ID:
369(Pulsechain mainnet) - Accounts: 10 pre-funded accounts
- Balance: 1000 PLS per account
- Gas Limit: 30M
- Host:
0.0.0.0(accessible from other machines)
The foundry.toml file is configured with:
- Pulsechain RPC endpoints
- Fork settings
- Compiler optimizations
- Test configurations
Edit the .env file to customize:
- RPC URLs
- API keys
- Private keys (for testing only)
- Fork block number
- Anvil settings
Test that your fork is working correctly:
forge script script/StartFork.s.sol --fork-url http://127.0.0.1:8545Deploy contracts to the local fork:
forge script script/YourScript.s.sol --fork-url http://127.0.0.1:8545 --broadcastRun tests against the fork:
forge test --fork-url http://127.0.0.1:8545Since this is a fork of Pulsechain, all existing contracts and their state are available. You can interact with them using their deployed addresses.
- RPC URL:
https://rpc.pulsechain.com - Chain ID:
369 - Block Explorer: PulseScan
- RPC URL:
https://rpc.v4.testnet.pulsechain.com - Chain ID:
943 - Block Explorer: Testnet PulseScan
# Build contracts
forge build
# Run tests
forge test
# Format code
forge fmt
# Get gas reports
forge test --gas-report
# Deploy and verify
forge script script/Deploy.s.sol --rpc-url pulsechain --broadcast --verify
# Check contract size
forge build --sizes# Start fork with specific block
anvil --fork-url https://rpc.pulsechain.com --fork-block-number 12345678
# Start fork with more accounts
anvil --fork-url https://rpc.pulsechain.com --accounts 20
# Start fork with custom balance
anvil --fork-url https://rpc.pulsechain.com --balance 10000├── src/ # Contract source files
├── test/ # Test files
├── script/ # Deployment and utility scripts
├── lib/ # Dependencies (forge-std)
├── foundry.toml # Foundry configuration
├── start-fork.sh # Fork startup script
├── env.example # Environment variables template
└── README.md # This file
- Never use real private keys with actual funds in this development environment
- The default private key in
env.exampleis a well-known test key - This fork is for development and testing purposes only
- Always test on testnets before mainnet deployment
Feel free to submit issues and enhancement requests!
This project is licensed under MIT License.
- Fork fails to start: Check your internet connection and Pulsechain RPC availability
- Out of gas errors: Increase gas limit in the start script
- Connection refused: Ensure Anvil is running and accessible on the specified port
Happy Forking! 🍴⛓️