Estimating Gas Price
This Estimating Gas Price using this method.
API Specification
Estimating Gas Price
POST http://localhost:8889/wallet/estimateGas
Submit Transaction under the given instance.
Headers
Name
Type
Description
ChainId*
String
ChainId
Request Body
Name
Type
Description
to*
String
The recipient's address
walletId*
String
The ID of the wallet
params*
String
Additional parameters for the transaction
method*
String
The method for the transaction
isContractTxn*
String
Indicates whether the transaction is a contract transaction
contractABI*
String
The Application Binary Interface (ABI) of the contract
{
  "Status": "SUCCESS",
  "Message": "",
  "Data": {
    "address": "0xa287e3DE5f629fc49321De34F40da40aAd799fa7",
    "estimatedGas": 23912
  }
}{
    "Status": "FAILURE",
    "Message": "error reading ABI : EOF",
    "Data": null
}Take a look at how you might call this method using our official libraries, or via curl:
curl -X POST http://localhost:8889/wallet/estimateGas \
-H "Content-Type: application/json" \
-H "ChainId: xxxx" \
-d '{
  "walletId": "effae2b6-3ee3-xxxxxxxxxxxxxxxxxxxxxxxxx",
  "to": "0xc2de797fab7d2d2b26xxxxxxxxxxxxxxxxxxxxxxxxx",
  "method": "store",
  "params": [
    {
      "type": "uint256",
      "value": "35"
    }
  ],
  "isContractTxn": true,
  "contractABI": "[]"
}'
const axios = require('axios');
const data = {
  walletId: 'effae2b6-3ee3-48cb-9528-87c29152c89e',
  to: '0xc2de797fab7d2d2b26246e93fcf2cd5873a90b10',
  method: 'store',
  params: [{ type: 'uint256', value: '35' }],
  isContractTxn: true,
  contractABI: '[]',
};
axios.post('http://localhost:8889/wallet/estimateGas', data, {
  headers: {
    'Content-Type': 'application/json',
    'ChainId': 'xxxx',
  },
})
  .then((response) => {
    console.log('Response:', response.data);
  })
  .catch((error) => {
    console.error('Error:', error);
  });
import requests
import json
url = 'http://localhost:8889/wallet/estimateGas'
headers = {'Content-Type': 'application/json', 'ChainId': 'xxxx'}
data = {
    "walletId": "effae2b6-3ee3-48cb-9528-87c29152c89e",
    "to": "0xc2de797fab7d2d2b26246e93fcf2cd5873a90b10",
    "method": "store",
    "params": [{"type": "uint256", "value": "35"}],
    "isContractTxn": True,
    "contractABI": '[{"inputs":[{"internalType":"uint256","name":"num","type":"uint256"}],"name":"store","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"retrieve","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]'
}
response = requests.post(url, data=json.dumps(data), headers=headers)
if response.status_code == 200:
    print('Response:', response.json())
else:
    print('Request failed with status code:', response.status_code)
package main
import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)
func main() {
  url := "http://localhost:8889/wallet/estimateGas"
  method := "POST"
  payload := strings.NewReader(`{
  "walletId": "effae2b6-3ee3-xxxxxxxxxxxxxxxxxxxxxxxxx",
  "to": "0xc2de797fab7d2d2b26xxxxxxxxxxxxxxxxxxxxxxxxx",
  "method": "store",
  "params": [
    {
      "type": "uint256",
      "value": "35"
    }
  ],
  "isContractTxn": true,
  "contractABI": "[]"
}`)
  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)
  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("ChainId", "xxxxxx")
  req.Header.Add("Content-Type", "application/json")
  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}Last updated
Was this helpful?