预估能量消耗

说明

由于波场质押能量实时变动。建议下单购买能量的数量,采用预估能量向上取整的值。具体根据业务需求自行判断。

接口地址

GET /v2/order/estimate_energy

请求参数

名称位置类型必选说明
from_addressquerystringtrue出款地址
contract_addressquerystringfalse合约地址(不填默认为USDT合约地址TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t)
to_addressquerystringtrue收款地址

接口返回

名称类型必选说明
codeintegertrue状态码
msgstringtrue状态说明
request_idstringtrue
dataobject
» from_addressstringtrue出款地址
» contract_addressstringtrue合约地址
» to_addressstringtrue收款地址
» energy_usedintegertrue预估能量消耗
» feenumbertrue预估能量消耗燃烧TRX

返回示例

{
    "code": 0,
    "msg": "ok",
    "request_id": "ffedfc9f-bd0b-4d56-bedf-0d54ff722e86",
    "data": {
        "from_address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
        "contract_address": "TXLAQ63Xg1NAzckPwKHvzw7CSEmLMEqcdj",
        "to_address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
        "energy_used": 13430,
        "fee": 5.6406
    }
}

代码示例

curl --location --request GET 'https://feee.io/open/v2/order/estimate_energy?from_address=<from_address>&contract_address=<contract_address>&to_address=<to_address>' \
--header 'key: <key>' \
--header 'User-Agent: Feee.io Client/1.0.0 (https://feee.io)'
package main

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

func main() {

   url := "https://feee.io/open/v2/order/estimate_energy?from_address=%3Cfrom_address%3E&contract_address=%3Ccontract_address%3E&to_address=%3Cto_address%3E"
   method := "GET"

   client := &http.Client {
   }
   req, err := http.NewRequest(method, url, nil)

   if err != nil {
      fmt.Println(err)
      return
   }
   req.Header.Add("key", "<key>")
   req.Header.Add("User-Agent", "Feee.io Client/1.0.0 (https://feee.io)")

   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))
}
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
   CURLOPT_URL => 'https://feee.io/open/v2/order/estimate_energy?from_address=%3Cfrom_address%3E&contract_address=%3Ccontract_address%3E&to_address=%3Cto_address%3E',
   CURLOPT_RETURNTRANSFER => true,
   CURLOPT_ENCODING => '',
   CURLOPT_MAXREDIRS => 10,
   CURLOPT_TIMEOUT => 0,
   CURLOPT_FOLLOWLOCATION => true,
   CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
   CURLOPT_CUSTOMREQUEST => 'GET',
   CURLOPT_HTTPHEADER => array(
      'key: <key>',
      'User-Agent: Feee.io Client/1.0.0 (https://feee.io)'
   ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


import http.client

conn = http.client.HTTPSConnection("feee.io")
payload = ''
headers = {
   'key': '<key>',
   'User-Agent': 'Feee.io Client/1.0.0 (https://feee.io)'
}
conn.request("GET", "/open/v2/order/estimate_energy?from_address=%3Cfrom_address%3E&contract_address=%3Ccontract_address%3E&to_address=%3Cto_address%3E", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
   .build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
   .url("https://feee.io/open/v2/order/estimate_energy?from_address=<from_address>&contract_address=<contract_address>&to_address=<to_address>")
   .method("GET", body)
   .addHeader("key", "<key>")
   .addHeader("User-Agent", "Feee.io Client/1.0.0 (https://feee.io)")
   .build();
Response response = client.newCall(request).execute();
上次更新: