Common Workflows
Here are some typical workflows for using the local testnet during development.
Smart Contract Deployment
-
Start the network:
make testnet-start -
Deploy your contract using Foundry:
forge create src/MyContract.sol:MyContract \ --rpc-url http://127.0.0.1:8545 \ --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 -
Verify in Otterscan:
- Open http://localhost:80
- Search for the contract address
- View deployment transaction and contract state
-
Interact with the contract:
cast call <CONTRACT_ADDRESS> "myFunction()" --rpc-url http://127.0.0.1:8545
Validator Set Changes
-
Start the network:
make testnet-start -
Check initial validator set:
cargo run --bin emerald-utils poa list -
Create a new validator key:
# replace ID with a specific node ID (e.g., 4) cargo run --bin emerald -- init --home nodes/{ID} -
Get the public key:
# replace ID with a specific node ID (e.g., 4) cargo run --bin emerald show-pubkey nodes/{ID}/config/priv_validator_key.json -
Add the validator to the network:
cargo run --bin emerald-utils poa add-validator \ --validator-pubkey <PUBKEY> \ --power 100 \ --owner-private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 -
Verify the change:
cargo run --bin emerald-utils poa list -
Start the new validator node (manual process, see node configuration)
Testing Under Load
-
Start the network:
make testnet-start -
Run the transaction spammer:
emerald-utils spam --chain-id 12345 \ --rpc-url http://127.0.0.1:8645 \ --rate 10 \ --duration 60 -
Monitor performance in Grafana:
- Open http://localhost:4000
- Watch block production rate
- Monitor transaction processing time
- Check for any consensus delays
-
Check mempool and logs:
# Check mempool size curl -X POST http://127.0.0.1:8645 \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"txpool_status","params":[],"id":1}' # Watch validator logs tail -f nodes/0/emerald.log
Application Integration
-
Start the network:
make testnet-start -
Configure your application to use:
- RPC URL:
http://127.0.0.1:8645 - Chain ID:
12345 - Test account private key (from pre-funded accounts)
- RPC URL:
-
Run your application and verify:
- Transactions are submitted successfully
- Events are emitted and captured correctly
- State changes are reflected
-
Use Otterscan to debug any issues:
- View transaction details
- Check revert reasons
- Inspect logs and events