Decode a function call data, error, or event log
Decode a function call data, error, or event log from a deployed contract by blockchain native asset id and contract address.
POST
/
contract_interactions
/
base_asset_id
/
{baseAssetId}
/
contract_address
/
{contractAddress}
/
decode
TypeScript
const response: Promise<FireblocksResponse<ContractDataDecodedResponse>> = fireblocks.contractInteractions.decodeContractData(contractInteractionsApiDecodeContractDataRequest);CompletableFuture<ApiResponse<ContractDataDecodedResponse>> response = fireblocks.contractInteractions().decodeContractData(contractDataDecodeRequest, contractAddress, baseAssetId, idempotencyKey);response = fireblocks.contract_interactions.decode_contract_data(contract_data_decode_request, contract_address, base_asset_id, idempotency_key);curl --request POST \
--url https://api.fireblocks.io/v1/contract_interactions/base_asset_id/{baseAssetId}/contract_address/{contractAddress}/decode \
--header 'Content-Type: application/json' \
--data '
{
"data": "0x1234567890abcdef",
"dataType": "FUNCTION",
"abi": [
{
"inputs": [
{
"name": "to",
"type": "address"
},
{
"name": "amount",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function",
"name": "transfer"
}
]
}
'const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
data: '0x1234567890abcdef',
dataType: 'FUNCTION',
abi: [
{
inputs: [{name: 'to', type: 'address'}, {name: 'amount', type: 'uint256'}],
stateMutability: 'nonpayable',
type: 'function',
name: 'transfer'
}
]
})
};
fetch('https://api.fireblocks.io/v1/contract_interactions/base_asset_id/{baseAssetId}/contract_address/{contractAddress}/decode', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.fireblocks.io/v1/contract_interactions/base_asset_id/{baseAssetId}/contract_address/{contractAddress}/decode",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data' => '0x1234567890abcdef',
'dataType' => 'FUNCTION',
'abi' => [
[
'inputs' => [
[
'name' => 'to',
'type' => 'address'
],
[
'name' => 'amount',
'type' => 'uint256'
]
],
'stateMutability' => 'nonpayable',
'type' => 'function',
'name' => 'transfer'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.fireblocks.io/v1/contract_interactions/base_asset_id/{baseAssetId}/contract_address/{contractAddress}/decode"
payload := strings.NewReader("{\n \"data\": \"0x1234567890abcdef\",\n \"dataType\": \"FUNCTION\",\n \"abi\": [\n {\n \"inputs\": [\n {\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"name\": \"amount\",\n \"type\": \"uint256\"\n }\n ],\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\",\n \"name\": \"transfer\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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))
}require 'uri'
require 'net/http'
url = URI("https://api.fireblocks.io/v1/contract_interactions/base_asset_id/{baseAssetId}/contract_address/{contractAddress}/decode")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": \"0x1234567890abcdef\",\n \"dataType\": \"FUNCTION\",\n \"abi\": [\n {\n \"inputs\": [\n {\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"name\": \"amount\",\n \"type\": \"uint256\"\n }\n ],\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\",\n \"name\": \"transfer\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"result": [
{
"name": "transfer",
"signature": "transfer(address,uint256)",
"args": [
{
"name": "_name",
"type": "string",
"description": "The name of the token",
"internalType": "string",
"components": [
{
"name": "_name",
"type": "string",
"description": "The name of the token",
"internalType": "string",
"components": "<array>"
}
],
"value": "true",
"functionValue": {
"inputs": "<array>",
"name": "initialize",
"outputs": "<array>",
"stateMutability": "nonpayable"
}
}
]
}
],
"type": "FUNCTION"
}{
"message": "Error decoding data: Invalid ABI",
"code": 400
}{
"message": "<string>",
"code": 123
}Headers
A unique identifier for the request. If the request is sent multiple times with the same idempotency key, the server will return the same response as the first request. The idempotency key is valid for 24 hours.
Path Parameters
The contract's onchain address
The blockchain native asset identifier
Body
application/json
The data to decode, which can be a string or an object containing the data and its type.
Example:
"0x1234567890abcdef"
The type of the data to decode.
Available options:
ERROR, LOG, FUNCTION Example:
"FUNCTION"
The abi of the function/error/log to decode.
Show child attributes
Show child attributes
Example:
[ { "inputs": [ { "name": "to", "type": "address" }, { "name": "amount", "type": "uint256" } ], "stateMutability": "nonpayable", "type": "function", "name": "transfer" } ]
Was this page helpful?
Previous
Return deployed contract's ABIReturn deployed contract's ABI by blockchain native asset id and contract address.
Endpoint Permission: Admin, Non-Signing Admin, Signer, Approver, Editor, and Viewer.
Next
⌘I
TypeScript
const response: Promise<FireblocksResponse<ContractDataDecodedResponse>> = fireblocks.contractInteractions.decodeContractData(contractInteractionsApiDecodeContractDataRequest);CompletableFuture<ApiResponse<ContractDataDecodedResponse>> response = fireblocks.contractInteractions().decodeContractData(contractDataDecodeRequest, contractAddress, baseAssetId, idempotencyKey);response = fireblocks.contract_interactions.decode_contract_data(contract_data_decode_request, contract_address, base_asset_id, idempotency_key);curl --request POST \
--url https://api.fireblocks.io/v1/contract_interactions/base_asset_id/{baseAssetId}/contract_address/{contractAddress}/decode \
--header 'Content-Type: application/json' \
--data '
{
"data": "0x1234567890abcdef",
"dataType": "FUNCTION",
"abi": [
{
"inputs": [
{
"name": "to",
"type": "address"
},
{
"name": "amount",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function",
"name": "transfer"
}
]
}
'const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
data: '0x1234567890abcdef',
dataType: 'FUNCTION',
abi: [
{
inputs: [{name: 'to', type: 'address'}, {name: 'amount', type: 'uint256'}],
stateMutability: 'nonpayable',
type: 'function',
name: 'transfer'
}
]
})
};
fetch('https://api.fireblocks.io/v1/contract_interactions/base_asset_id/{baseAssetId}/contract_address/{contractAddress}/decode', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.fireblocks.io/v1/contract_interactions/base_asset_id/{baseAssetId}/contract_address/{contractAddress}/decode",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data' => '0x1234567890abcdef',
'dataType' => 'FUNCTION',
'abi' => [
[
'inputs' => [
[
'name' => 'to',
'type' => 'address'
],
[
'name' => 'amount',
'type' => 'uint256'
]
],
'stateMutability' => 'nonpayable',
'type' => 'function',
'name' => 'transfer'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.fireblocks.io/v1/contract_interactions/base_asset_id/{baseAssetId}/contract_address/{contractAddress}/decode"
payload := strings.NewReader("{\n \"data\": \"0x1234567890abcdef\",\n \"dataType\": \"FUNCTION\",\n \"abi\": [\n {\n \"inputs\": [\n {\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"name\": \"amount\",\n \"type\": \"uint256\"\n }\n ],\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\",\n \"name\": \"transfer\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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))
}require 'uri'
require 'net/http'
url = URI("https://api.fireblocks.io/v1/contract_interactions/base_asset_id/{baseAssetId}/contract_address/{contractAddress}/decode")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": \"0x1234567890abcdef\",\n \"dataType\": \"FUNCTION\",\n \"abi\": [\n {\n \"inputs\": [\n {\n \"name\": \"to\",\n \"type\": \"address\"\n },\n {\n \"name\": \"amount\",\n \"type\": \"uint256\"\n }\n ],\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\",\n \"name\": \"transfer\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"result": [
{
"name": "transfer",
"signature": "transfer(address,uint256)",
"args": [
{
"name": "_name",
"type": "string",
"description": "The name of the token",
"internalType": "string",
"components": [
{
"name": "_name",
"type": "string",
"description": "The name of the token",
"internalType": "string",
"components": "<array>"
}
],
"value": "true",
"functionValue": {
"inputs": "<array>",
"name": "initialize",
"outputs": "<array>",
"stateMutability": "nonpayable"
}
}
]
}
],
"type": "FUNCTION"
}{
"message": "Error decoding data: Invalid ABI",
"code": 400
}{
"message": "<string>",
"code": 123
}