Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Common Workflows

Here are some typical workflows for using the local testnet during development.

Smart Contract Deployment

  1. Start the network:

    make testnet-start
    
  2. Deploy your contract using Foundry:

    forge create src/MyContract.sol:MyContract \
      --rpc-url http://127.0.0.1:8545 \
      --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
    
  3. Verify in Otterscan:

    • Open http://localhost:80
    • Search for the contract address
    • View deployment transaction and contract state
  4. Interact with the contract:

    cast call <CONTRACT_ADDRESS> "myFunction()" --rpc-url http://127.0.0.1:8545
    

Validator Set Changes

  1. Start the network:

    make testnet-start
    
  2. Check initial validator set:

    cargo run --bin emerald-utils poa list
    
  3. Create a new validator key:

    # replace ID with a specific node ID (e.g., 4)
    cargo run --bin emerald -- init --home nodes/{ID}
    
  4. 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
    
  5. Add the validator to the network:

    cargo run --bin emerald-utils poa add-validator \
      --validator-pubkey <PUBKEY> \
      --power 100 \
      --owner-private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
    
  6. Verify the change:

    cargo run --bin emerald-utils poa list
    
  7. Start the new validator node (manual process, see node configuration)

Testing Under Load

  1. Start the network:

    make testnet-start
    
  2. Run the transaction spammer:

    emerald-utils spam --chain-id 12345 \
      --rpc-url http://127.0.0.1:8645 \
      --rate 10 \
      --duration 60
    
  3. Monitor performance in Grafana:

    • Open http://localhost:4000
    • Watch block production rate
    • Monitor transaction processing time
    • Check for any consensus delays
  4. 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

  1. Start the network:

    make testnet-start
    
  2. Configure your application to use:

    • RPC URL: http://127.0.0.1:8645
    • Chain ID: 12345
    • Test account private key (from pre-funded accounts)
  3. Run your application and verify:

    • Transactions are submitted successfully
    • Events are emitted and captured correctly
    • State changes are reflected
  4. Use Otterscan to debug any issues:

    • View transaction details
    • Check revert reasons
    • Inspect logs and events