Insufficient funds being reported as a CALL_EXCEPTION
Ethers Version
6.13.4
Search Terms
No response
Describe the Problem
An insufficient funds error is being reported as "CALL_EXCEPTION" with a short message of "missing revert data."
This occurs when simulating a transaction, i.e. making a static call with a hard-coded gas limit (I don't know if the hard-coded gas limit has any impact).
Call stack:
at makeError (REDACTED/node_modules/ethers/src.ts/utils/errors.ts:694:21)
at getBuiltinCallException (REDACTED/node_modules/ethers/src.ts/abi/abi-coder.ts:118:21)
at Function.getBuiltinCallException (REDACTED/node_modules/ethers/src.ts/abi/abi-coder.ts:235:16)
at JsonRpcProvider.getRpcError (REDACTED/node_modules/ethers/src.ts/providers/provider-jsonrpc.ts:989:32)
at REDACTED/node_modules/ethers/src.ts/providers/provider-jsonrpc.ts:563:45
at processTicksAndRejections (node:internal/process/task_queues:105:5)",
Code Snippet
Contract ABI
Errors
"error": {
"code": "CALL_EXCEPTION",
"shortMessage": "missing revert data",
"action": "call",
"transaction": {
"data": REDACTED,
"from": REDACTED,
"to": REDACTED
},
"info": {
"payload": {
"method": "eth_call",
"id": 42,
"jsonrpc": "2.0",
"params": [
{
"data": REDACTED,
"gas": "0x989680",
"from": REDACTED,
"to": REDACTED,
"type": "0x0",
"nonce": "0x0",
"gasPrice": "0xf4482"
},
"latest"
]
},
"error": {
"code": -32000,
"message": "err: insufficient funds for gas * price + value: address REDACTED have 0 want 10005780000000 (supplied gas 10000000)"
}
}
},
Environment
node.js (v12 or newer)
Environment (Other)
No response
I don't believe the static gasLimit is the issue. The node is checking the sender has sufficient ether to execute the transaction, which it doesn't.
Does the simulated sender have ether? I also notice that the type is 0. What network are you interacting with?
At the very least, this looks like it is returning the wrong error, as it is a protocol error, not a call revert. Occasionally the nodes change the wording of errors, and ethers uses a plethora of string matching to coalesce the human-readable errors from nodes into consistent errors. What node and network are you working with? Usually an insufficient funds error is only caused by sending a transaction or estimateGas. I may have to add call to that list... :s
Thanks for taking a look at this @ricmoo.
The account indeed did not have any Ether. The problem is that Ethers is returning the wrong error. For me, this misclassification makes it challenging to diagnose and respond to issues with the infrastructure that I run.
I experienced this issue when interacting with Optimism and all of the following RPC providers: DRPC, Blast API, Nodies, Infura, Ankr, mainnet.optimism.io, and Alchemy.