POST /state/abi/bin_to_json
stable
Decode binary rows (in hexadecimal string) for a given table against the ABI of a given contract account, at any block height.
Usage
Sample request:
curl -X POST -H "Authorization: Bearer eyJhbGciOiJLTVNFUzI1Ni..." \
-d '{"account":"eosio.token","table":"accounts","block_num":2500000,"hex_rows":["aa2c0b010000000004454f5300000000"]}' \
"https://eos.dfuse.eosnation.io/v0/state/abi/bin_to_json"
fetch("https://eos.dfuse.eosnation.io/v0/state/abi/bin_to_json", {
method: "POST",
body: JSON.stringify({
account: "eosio.token",
table: "accounts",
block_num: 2500000,
hex_rows: ["aa2c0b010000000004454f5300000000"]
}),
headers: {
Authorization: "Bearer eyJhbGciOiJLTVNFUzI1Ni...",
"Content-Type": "application/x-www-form-urlencoded"
}
}).then(console.log)
import requests
headers = {
'Authorization': 'Bearer eyJhbGciOiJLTVNFUzI1Ni...',
}
data = '{"account":"eosio.token","table":"accounts","block_num":2500000,"hex_rows":["aa2c0b010000000004454f5300000000"]}'
response = requests.post('https://eos.dfuse.eosnation.io/v0/state/abi/bin_to_json', headers=headers, data=data)
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
func main() {
client := &http.Client{}
var data = []byte(`{{"account":"eosio.token","table":"accounts","block_num":2500000,"hex_rows":["aa2c0b010000000004454f5300000000"]}}`)
req, err := http.NewRequest("POST", "https://eos.dfuse.eosnation.io/v0/state/abi/bin_to_json", data)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer eyJhbGciOiJLTVNFUzI1Ni...")
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
bodyText, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", bodyText)
}
Requesting past blocks
The block_num
parameter determines for which block you want to decode rows
against. This can be anywhere in the chain’s history.
If the requested block_num
is irreversible, decoding will be performed
against an immutable ABI. If the ABI has changed while still in a reversible
chain, decoding will be performed against this new ABI, but it is not guaranteed
to be the view that will pass irreversibility. Inspect the returned block_num
parameter of the response to understand from which longest chain the returned ABI is from.
Input Parameters
The input body must be a valid JSON object. Here are the fields accepted in this JSON object.
accounts
table. Refer to the contract’s ABI for a list of available tables. This is contract dependent.
block_num
.
Response
block_num
at which the ABI was put on chain. For example, if ABI was last changed at block 1000 and you used a block_num
of 20000 in the request, the response block_num
will be 1000.
block_num
. Order of hex_rows
request parameter is preserved.
Here is a sample response, for a request at block_num: 8000
:
{
"block_num": 181,
"account": "eosio.token",
"table": "accounts",
"rows": [
{
"balance": "1750.9546 EOS"
},
...
]
}