qan_estimateGas

post

https://rpc-testnet.qanplatform.com/estimateGas/

API details

Returns an estimation of gas for a given transaction.

Request body for "qan_estimateGas"

Objectobject

The state override set with address-to-state mapping where each address maps to an object containing

Balancestring

Fake balance to set for the account before executing the call

Codeinteger

Fake EVM bytecode to inject into the account before executing the call

Noncestring

Fake nonce to set for the account before executing the call

Statestring

Fake key-value mapping to override all slots in the account storage before executing the call

StateDiffstring

Fake key-value mapping to override individual slots in the account storage before executing the call

TransactionobjectRequired

The transaction call object

Datastring

The hash of the method signature and encoded parameters. For more information, see the Contract ABI description in the Solidity documentation.

Fromstring

The address from which the transaction is sent

Gasstring

The integer of gas provided for the transaction execution

GasPricestring

The integer of gasPrice used for each paid gas encoded as hexadecimal

TostringRequired

The address to which the transaction is addressed

Valuestring

The integer of value sent with this transaction encoded as hexadecimal

HTTP response status codes for "qan_estimateGas"

Status Code Description
200 OK
400 Bad Request
404 Not Found
422 Unprocessable Entity
500 Internal Server Error

Code samples for "qan_estimateGas"

Request examples

post

https://rpc-testnet.qanplatform.com/estimateGas/

cURLJavaScriptGoPythonJava
curl --request POST \
  --url https://rpc-testnet.qanplatform.com/estimateGas/ \
  --header 'Accept: application/json, application/problem+json' \
  --header 'Content-Type: application/json' \
  --data '
{
"Object": {
  "Balance": "string",
  "Code": "0",
  "Nonce": "string",
  "State": "string",
  "StateDiff": "string"
},
"Transaction": {
  "Data": "string",
  "From": "string",
  "Gas": "string",
  "GasPrice": "string",
  "To": "string",
  "Value": "string"
}
}
'
const options = {
  method: 'POST',
  headers: {
    Accept: 'application/json, application/problem+json',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    Object: {
        Balance: 'string',
        Code: '0',
        Nonce: 'string',
        State: 'string',
        StateDiff: 'string'
    },
    Transaction: {
        Data: 'string',
        From: 'string',
        Gas: 'string',
        GasPrice: 'string',
        To: 'string',
        Value: 'string'
    }
  })
};

fetch('https://rpc-testnet.qanplatform.com/estimateGas/', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io"
)

func main() {

  url := "https://rpc-testnet.qanplatform.com/estimateGas/"

  payload := strings.NewReader("{\"Object\":{\"Balance\":\"string\",\"Code\":\"0\",\"Nonce\":\"string\",\"State\":\"string\",\"StateDiff\":\"string\"},\"Transaction\":{\"Data\":\"string\",\"From\":\"string\",\"Gas\":\"string\",\"GasPrice\":\"string\",\"To\":\"string\",\"Value\":\"string\"}}")

  req, _ := http.NewRequest("POST", url, payload)

  req.Header.Add("Accept", "application/json, application/problem+json")
  req.Header.Add("Content-Type", "application/json")

  res, _ := http.DefaultClient.Do(req)

  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)

  fmt.Println(string(body))

}
import requests

url = "https://rpc-testnet.qanplatform.com/estimateGas/"

payload = {
  "Object": {
    "Balance": "string",
    "Code": "0",
    "Nonce": "string",
    "State": "string",
    "StateDiff": "string"
  },
  "Transaction": {
    "Data": "string",
    "From": "string",
    "Gas": "string",
    "GasPrice": "string",
    "To": "string",
    "Value": "string"
  }
}
headers = {
  "Accept": "application/json, application/problem+json",
  "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
HttpResponse<String> response = Unirest.post("https://rpc-testnet.qanplatform.com/estimateGas/")
  .header("Accept", "application/json, application/problem+json")
  .header("Content-Type", "application/json")
  .body("{\"Object\":{\"Balance\":\"string\",\"Code\":\"0\",\"Nonce\":\"string\",\"State\":\"string\",\"StateDiff\":\"string\"},\"Transaction\":{\"Data\":\"string\",\"From\":\"string\",\"Gas\":\"string\",\"GasPrice\":\"string\",\"To\":\"string\",\"Value\":\"string\"}}")
  .asString();

Responses

200400404422500

Description: OK

Content type: application/json

Example

{
  "$schema": "https://rpc-testnet.qanplatform.com/schemas/Output_estimateGas.json",
  "EstimatedGas": "string"
}

Body

$schemastring<uri>

A URL to the JSON Schema for this object.

Example:https://rpc-testnet.qanplatform.com/schemas/Output_estimateGas.json

EstimatedGasstringRequired

The estimated amount of gas used

Description: Bad Request

Content type: application/problem+json

Example

{
  "$schema": "https://rpc-testnet.qanplatform.com/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Body

$schemastring<uri>

A URL to the JSON Schema for this object.

Example:https://rpc-testnet.qanplatform.com/schemas/ErrorModel.json

detailstring

A human-readable explanation specific to this occurrence of the problem.

Example:Property foo is required but is missing.

errorsarray[object]

Optional list of individual error details

locationstring

Where the error occurred, e.g. 'body.items3.tags' or 'path.thing-id'

messagestring

Error message text

valueany

The value at the given location

instancestring<uri>

A URI reference that identifies the specific occurrence of the problem.

Example:https://example.com/error-log/abc123

statusinteger<int64>

HTTP status code

Example:400

titlestring

A short, human-readable summary of the problem type. This value should not change between occurrences of the error.

Example:Bad Request

typestring<uri>

A URI reference to human-readable documentation for the error.

Default:about:blank

Example:https://example.com/errors/example

Description: Not Found

Content type: application/problem+json

Example

{
  "$schema": "https://rpc-testnet.qanplatform.com/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Body

$schemastring<uri>

A URL to the JSON Schema for this object.

Example:https://rpc-testnet.qanplatform.com/schemas/ErrorModel.json

detailstring

A human-readable explanation specific to this occurrence of the problem.

Example:Property foo is required but is missing.

errorsarray[object]

Optional list of individual error details

locationstring

Where the error occurred, e.g. 'body.items3.tags' or 'path.thing-id'

messagestring

Error message text

valueany

The value at the given location

instancestring<uri>

A URI reference that identifies the specific occurrence of the problem.

Example:https://example.com/error-log/abc123

statusinteger<int64>

HTTP status code

Example:400

titlestring

A short, human-readable summary of the problem type. This value should not change between occurrences of the error.

Example:Bad Request

typestring<uri>

A URI reference to human-readable documentation for the error.

Default:about:blank

Example:https://example.com/errors/example

Description: Unprocessable Entity

Content type: application/problem+json

Example

{
  "$schema": "https://rpc-testnet.qanplatform.com/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Body

$schemastring<uri>

A URL to the JSON Schema for this object.

Example:https://rpc-testnet.qanplatform.com/schemas/ErrorModel.json

detailstring

A human-readable explanation specific to this occurrence of the problem.

Example:Property foo is required but is missing.

errorsarray[object]

Optional list of individual error details

locationstring

Where the error occurred, e.g. 'body.items3.tags' or 'path.thing-id'

messagestring

Error message text

valueany

The value at the given location

instancestring<uri>

A URI reference that identifies the specific occurrence of the problem.

Example:https://example.com/error-log/abc123

statusinteger<int64>

HTTP status code

Example:400

titlestring

A short, human-readable summary of the problem type. This value should not change between occurrences of the error.

Example:Bad Request

typestring<uri>

A URI reference to human-readable documentation for the error.

Default:about:blank

Example:https://example.com/errors/example

Description: Internal Server Error

Content type: application/problem+json

Example

{
  "$schema": "https://rpc-testnet.qanplatform.com/schemas/ErrorModel.json",
  "detail": "Property foo is required but is missing.",
  "errors": [],
  "instance": "https://example.com/error-log/abc123",
  "status": 400,
  "title": "Bad Request",
  "type": "https://example.com/errors/example"
}

Body

$schemastring<uri>

A URL to the JSON Schema for this object.

Example:https://rpc-testnet.qanplatform.com/schemas/ErrorModel.json

detailstring

A human-readable explanation specific to this occurrence of the problem.

Example:Property foo is required but is missing.

errorsarray[object]

Optional list of individual error details

locationstring

Where the error occurred, e.g. 'body.items3.tags' or 'path.thing-id'

messagestring

Error message text

valueany

The value at the given location

instancestring<uri>

A URI reference that identifies the specific occurrence of the problem.

Example:https://example.com/error-log/abc123

statusinteger<int64>

HTTP status code

Example:400

titlestring

A short, human-readable summary of the problem type. This value should not change between occurrences of the error.

Example:Bad Request

typestring<uri>

A URI reference to human-readable documentation for the error.

Default:about:blank

Example:https://example.com/errors/example

Previous

qan_chainId

Next

qan_feeHistory