Gas
Estimate gas
POST /v1/gas/estimate returns a gas limit and fee tiers for an EVM transaction.
Endpoint
POST/v1/gas/estimate
Optional to, data, and value describe the call to estimate.
Request
curl -sS -X POST "https://blockchain.gray3.io/v1/gas/estimate" \
-H "X-Gray-Project-Id: proj_your_project_id" \
-H "Authorization: Bearer gray_sk_your_secret" \
-H "Content-Type: application/json" \
-d '{
"chainId": "ethereum",
"from": "0xYourAddress",
"to": "0xRecipient",
"value": "1000000000000000"
}'Response
HTTP 200 — success envelope wraps the payload in data.
json
{
"data": {
"chainId": "ethereum",
"gasLimit": "21000",
"estimatedFeeWei": "630000000000000",
"fees": {
"chainId": "ethereum",
"slow": {},
"average": {},
"fast": {},
"source": "indexer"
},
"source": "indexer"
}
}Errors
Errors use HTTP { "error": { "code", "message", "retryable" } }. Branch on code, not the message text.
Every authenticated route may also return unauthorized (401), revoked_secret (401), forbidden (403), credits_exhausted (402), plan_feature_denied (403), rate_limit_exceeded (429, retryable), and invalid_argument (413) for request bodies over 256 KiB.
| Code | HTTP | When |
|---|---|---|
| invalid_argument | 400 | Missing or malformed chainId, address, or body fields |
| plan_chain_denied | 403 | chainId is not on the project plan |
| chain_disabled | 403 | Chain turned off in Console › Networks |
| unsupported_capability | 400 | Capability not offered for this chain (e.g. testnet prices) |
| invalid_argument | 400 | Missing chainId or from address on estimate |
| gas_unavailable | 503 | Gas provider failed (retryable) |
| simulation_failed | 400 | Estimate could not simulate the call (use /transactions/simulate for full dry-run) |
json
{
"error": {
"code": "invalid_argument",
"message": "Human-readable detail (may be sanitized).",
"retryable": false
}
}