Files
proxmox/docs/09-troubleshooting/RPC_ERRORS_32001_32602.md
defiQUG e4c9dda0fd
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
chore: update submodule references and documentation
- Marked submodules ai-mcp-pmm-controller, explorer-monorepo, and smom-dbis-138 as dirty to reflect recent changes.
- Updated documentation to clarify operator script usage, including dotenv loading and task execution instructions.
- Enhanced the README and various index files to provide clearer navigation and task completion guidance.

Made-with: Cursor
2026-03-04 02:03:08 -08:00

7.1 KiB
Raw Blame History

Preventing RPC Errors -32001, -32602, and Gas-Related 32xxx

Purpose: How to avoid and fix common JSON-RPC errors when deploying or sending transactions to Chain 138: -32001 (Nonce too low), -32602 (Invalid params), and gas-related -32xxx (e.g. -32000 execution reverted / out of gas).


Meaning: The node rejected the transaction due to gas: execution reverted, out of gas, or gas estimation failed. Error code is often -32000 (generic) or -32602 (when the failure happens inside eth_estimateGas).

Causes

  1. Gas estimate too low
    Forge uses eth_estimateGas and multiplies by 130% by default. On some nodes or for heavy contracts that can still be too low, so the broadcast tx runs out of gas.

  2. Insufficient balance for gas
    Deployer doesnt have enough native ETH to pay for (estimate × gas price).

  3. RPC returns bad estimate
    Some Besu/Chain 138 nodes return a low or failing eth_estimateGas, which then leads to a failed or reverted tx.

Prevention

What you do How to prevent gas 32xxx
Increase gas estimate multiplier Run forge script with --gas-estimate-multiplier 150 or 200 so the broadcast uses 150% or 200% of the estimated gas (default is 130%). Example: forge script ... --broadcast --with-gas-price 1000000000 --gas-estimate-multiplier 150.
Fund deployer Ensure deployer has enough native ETH on Chain 138. Preflight and check-balances-gas-and-deploy.sh check this. Recommended ≥ 0.006 ETH; 12 ETH for larger deploys.
Use correct gas price Chain 138: use --with-gas-price 1000000000 (1 gwei). So scripts dont underpay and get rejected.
Explicit gas limit (cast) For cast send, pass --gas-limit <value> to avoid relying on eth_estimateGas when that call is flaky (-32602).

Fix when it happens

  1. Retry with higher multiplier:
    forge script ... --broadcast --with-gas-price 1000000000 --gas-estimate-multiplier 200
  2. Check deployer balance:
    cast balance $DEPLOYER --rpc-url $RPC_URL_138
    Fund the deployer if needed.
  3. If estimation keeps failing (-32602): Use a script that doesnt rely on estimation (e.g. cast send with explicit --gas-limit), or use a different RPC that supports eth_estimateGas correctly.

-32001: Nonce too low

Meaning: The node rejected the transaction because the nonce you used is lower than the next expected nonce for that account (e.g. you used N but the chain already has or has pending txs with N and N+1).

Causes

  1. Back-to-back txs in the same session
    You sent two transactions (e.g. two mints), then immediately ran a third (e.g. add-liquidity). The RPC may still return the old nonce when the broadcast runs, so the third tx is sent with an already-used nonce.

  2. Stuck or pending transactions
    Earlier txs are stuck in the mempool; the next nonce the RPC returns is still the one already used by the stuck tx.

  3. Multiple processes or scripts
    Two scripts (or two terminals) sending from the same account at once.

Prevention

What you do How to prevent -32001
Run preflight before deploy/script ./scripts/deployment/preflight-chain138-deploy.sh — fails if pending nonce > latest (stuck txs). Fix with ./scripts/clear-all-transaction-pools.sh then wait ~60s.
Mint then add-liquidity in one script Use ./scripts/mint-for-liquidity.sh --add-liquidity. It sets NEXT_NONCE from the pending nonce after mints so the add-liquidity broadcast uses the correct next nonce.
Run Forge scripts after other txs Export the next nonce before forge script: export NEXT_NONCE=$(cast nonce $DEPLOYER --rpc-url $RPC --block pending) then run the script. Use scripts that support NEXT_NONCE (e.g. AddLiquidityPMMPoolsChain138, DeployTransactionMirror, CreateCUSDTCUSDCPool).
Use deploy scripts that manage nonce ./scripts/deployment/deploy-transaction-mirror-and-pmm-pool-after-txpool-clear.sh reads pending nonce and sets NEXT_NONCE for each broadcast.

Fix when it happens

  1. Check current nonce:
    cast nonce <DEPLOYER> --rpc-url $RPC_URL_138 --block pending
  2. If stuck txs: Run ./scripts/clear-all-transaction-pools.sh, wait ~60s, then retry.
  3. Retry with explicit nonce:
    NEXT_NONCE=<pending_nonce> forge script ... --broadcast ...
    (Only for scripts that support NEXT_NONCE; see above.)

-32602: Invalid params

Meaning: The RPC server rejected the request because one or more parameters are invalid (wrong format, wrong chain, or unsupported).

Causes

  1. Wrong RPC / wrong chain
    Using an RPC URL for a different chain (e.g. mainnet) when sending a Chain 138 transaction, or vice versa.

  2. eth_estimateGas or other method returning -32602
    Some Besu/Chain 138 nodes return -32602 for certain calls (e.g. eth_estimateGas with a particular tx). Using an explicit gas limit avoids calling eth_estimateGas.

  3. Malformed or missing env
    Typos in .env (e.g. PRIVATE_KEYIT_ID), or missing RPC_URL_138 / PRIVATE_KEY so the client sends bad params.

Prevention

What you do How to prevent -32602
Use the correct RPC Chain 138: RPC_URL_138 (Core), e.g. http://192.168.11.211:8545. Verify: curl -s -X POST $RPC_URL_138 -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}'"result":"0x8a".
Preflight ./scripts/deployment/preflight-chain138-deploy.sh checks that the RPC returns chainId 0x8a (138).
Explicit gas limit For cast send, add --gas-limit 200000 (or appropriate value) so the client does not call eth_estimateGas. Example: cast send ... --gas-limit 200000.
Check env Run ./scripts/deployment/check-env-required.sh (or preflight) and fix any missing/typo vars in smom-dbis-138/.env.

Fix when it happens

  1. Confirm RPC URL and chainId (see above).
  2. If the error occurs during gas estimation, retry with an explicit --gas-limit (and, for Forge, --with-gas-limit if supported).
  3. Double-check .env and that the script is sourcing the correct file (smom-dbis-138/.env for deploy/Chain 138).

Quick checklist before sending Chain 138 transactions

  1. Run preflight:
    ./scripts/deployment/preflight-chain138-deploy.sh
  2. If you just sent other txs from the same account (e.g. mints), use NEXT_NONCE or a script that sets it (e.g. mint-for-liquidity.sh --add-liquidity).
  3. Use Core RPC for 138 (RPC_URL_138), and explicit gas limit where youve seen -32602 before.
  4. For deployments, use --gas-estimate-multiplier 150 (or 200) with forge script ... --broadcast to avoid gas-related -32xxx; ensure deployer has enough ETH for gas.

See also: CONTRACT_DEPLOYMENT_RUNBOOK.md, DEPLOYMENT_ORDER_OF_OPERATIONS.md.