Estimate contract gas
estimate_contract_gasEstimate the gas a contract function call would use from a given address, plus its cost at the current gas price, without signing or sending anything. Reveals revert reasons.
Instructions
Estimate the gas a contract function call would use if sent from from_address, and its cost at the current gas price. Nothing is signed or sent. A call that would revert returns success false with the reason in error.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"contract_address": "<contract_address>",
"function_name": "<function_name>",
"abi": "<abi>",
"from_address": "<from_address>"
},
"name": "estimate_contract_gas"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| abi | Yes | The contract ABI, as a JSON array or a JSON string. Only the entry for function_name is needed. | |
| value | No | CELO to send with the call, in wei. | 0 |
| from_address | Yes | The address the call would be sent from. | |
| function_args | No | Positional arguments for the function. | |
| function_name | Yes | The function to estimate, as named in the ABI. | |
| contract_address | Yes | The contract address. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| error | No | Error message if failed | |
| success | Yes | Whether estimation was successful | |
| gas_price | Yes | Current gas price | |
| total_cost | Yes | Total cost in wei | |
| gas_estimate | Yes | Estimated gas limit | |
| function_name | Yes | Function name | |
| contract_address | Yes | Contract address |