Call a read function on a deployed contract
Call a read function on a deployed contract by blockchain native asset id and contract address
const response: Promise<FireblocksResponse<ParameterWithValueList>> = fireblocks.contractInteractions.readCallFunction(contractInteractionsApiReadCallFunctionRequest);CompletableFuture<ApiResponse<List<ParameterWithValue>>> response = fireblocks.contractInteractions().readCallFunction(readCallFunctionDto, contractAddress, baseAssetId, idempotencyKey);response = fireblocks.contract_interactions.read_call_function(read_call_function_dto, 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}/functions/read \
--header 'Content-Type: application/json' \
--data '
{
"abiFunction": {
"stateMutability": "pure",
"type": "<string>",
"inputs": [
{
"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"
}
],
"outputs": [
{
"name": "_name",
"type": "string",
"description": "The name of the token",
"internalType": "string",
"components": "<array>"
}
],
"name": "<string>",
"description": "<string>"
}
}
'const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
abiFunction: {
stateMutability: 'pure',
type: '<string>',
inputs: [
{
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'
}
],
outputs: [
{
name: '_name',
type: 'string',
description: 'The name of the token',
internalType: 'string',
components: '<array>'
}
],
name: '<string>',
description: '<string>'
}
})
};
fetch('https://api.fireblocks.io/v1/contract_interactions/base_asset_id/{baseAssetId}/contract_address/{contractAddress}/functions/read', 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}/functions/read",
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([
'abiFunction' => [
'stateMutability' => 'pure',
'type' => '<string>',
'inputs' => [
[
'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'
]
],
'outputs' => [
[
'name' => '_name',
'type' => 'string',
'description' => 'The name of the token',
'internalType' => 'string',
'components' => '<array>'
]
],
'name' => '<string>',
'description' => '<string>'
]
]),
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}/functions/read"
payload := strings.NewReader("{\n \"abiFunction\": {\n \"stateMutability\": \"pure\",\n \"type\": \"<string>\",\n \"inputs\": [\n {\n \"name\": \"_name\",\n \"type\": \"string\",\n \"description\": \"The name of the token\",\n \"internalType\": \"string\",\n \"components\": [\n {\n \"name\": \"_name\",\n \"type\": \"string\",\n \"description\": \"The name of the token\",\n \"internalType\": \"string\",\n \"components\": \"<array>\"\n }\n ],\n \"value\": \"true\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"_name\",\n \"type\": \"string\",\n \"description\": \"The name of the token\",\n \"internalType\": \"string\",\n \"components\": \"<array>\"\n }\n ],\n \"name\": \"<string>\",\n \"description\": \"<string>\"\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}/functions/read")
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 \"abiFunction\": {\n \"stateMutability\": \"pure\",\n \"type\": \"<string>\",\n \"inputs\": [\n {\n \"name\": \"_name\",\n \"type\": \"string\",\n \"description\": \"The name of the token\",\n \"internalType\": \"string\",\n \"components\": [\n {\n \"name\": \"_name\",\n \"type\": \"string\",\n \"description\": \"The name of the token\",\n \"internalType\": \"string\",\n \"components\": \"<array>\"\n }\n ],\n \"value\": \"true\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"_name\",\n \"type\": \"string\",\n \"description\": \"The name of the token\",\n \"internalType\": \"string\",\n \"components\": \"<array>\"\n }\n ],\n \"name\": \"<string>\",\n \"description\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body[
{
"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"
}
}
]{
"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
Body
- Option 1
- Option 2
Show child attributes
Show child attributes
Response
Read Call Retrieved Successfully
The name of the parameter as it appears in the ABI
"_name"
The type of the parameter as it appears in the ABI
"string"
A description of the parameter, fetched from the devdoc of this contract
"The name of the token"
The internal type of the parameter as it appears in the ABI
"string"
Show child attributes
Show child attributes
The value of the parameter. The shape follows the ABI type: a string for string/address/bytes*, a number for uint*/int*, a boolean for bool, an array for T[], and for tuple an array of nested ParameterWithValue objects (one per entry in components, in ABI order).
"true"
The function value of this param (if has one). If this is set, the value shouldn`t be. Used for proxies
Show child attributes
Show child attributes
Was this page helpful?
const response: Promise<FireblocksResponse<ParameterWithValueList>> = fireblocks.contractInteractions.readCallFunction(contractInteractionsApiReadCallFunctionRequest);CompletableFuture<ApiResponse<List<ParameterWithValue>>> response = fireblocks.contractInteractions().readCallFunction(readCallFunctionDto, contractAddress, baseAssetId, idempotencyKey);response = fireblocks.contract_interactions.read_call_function(read_call_function_dto, 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}/functions/read \
--header 'Content-Type: application/json' \
--data '
{
"abiFunction": {
"stateMutability": "pure",
"type": "<string>",
"inputs": [
{
"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"
}
],
"outputs": [
{
"name": "_name",
"type": "string",
"description": "The name of the token",
"internalType": "string",
"components": "<array>"
}
],
"name": "<string>",
"description": "<string>"
}
}
'const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
abiFunction: {
stateMutability: 'pure',
type: '<string>',
inputs: [
{
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'
}
],
outputs: [
{
name: '_name',
type: 'string',
description: 'The name of the token',
internalType: 'string',
components: '<array>'
}
],
name: '<string>',
description: '<string>'
}
})
};
fetch('https://api.fireblocks.io/v1/contract_interactions/base_asset_id/{baseAssetId}/contract_address/{contractAddress}/functions/read', 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}/functions/read",
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([
'abiFunction' => [
'stateMutability' => 'pure',
'type' => '<string>',
'inputs' => [
[
'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'
]
],
'outputs' => [
[
'name' => '_name',
'type' => 'string',
'description' => 'The name of the token',
'internalType' => 'string',
'components' => '<array>'
]
],
'name' => '<string>',
'description' => '<string>'
]
]),
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}/functions/read"
payload := strings.NewReader("{\n \"abiFunction\": {\n \"stateMutability\": \"pure\",\n \"type\": \"<string>\",\n \"inputs\": [\n {\n \"name\": \"_name\",\n \"type\": \"string\",\n \"description\": \"The name of the token\",\n \"internalType\": \"string\",\n \"components\": [\n {\n \"name\": \"_name\",\n \"type\": \"string\",\n \"description\": \"The name of the token\",\n \"internalType\": \"string\",\n \"components\": \"<array>\"\n }\n ],\n \"value\": \"true\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"_name\",\n \"type\": \"string\",\n \"description\": \"The name of the token\",\n \"internalType\": \"string\",\n \"components\": \"<array>\"\n }\n ],\n \"name\": \"<string>\",\n \"description\": \"<string>\"\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}/functions/read")
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 \"abiFunction\": {\n \"stateMutability\": \"pure\",\n \"type\": \"<string>\",\n \"inputs\": [\n {\n \"name\": \"_name\",\n \"type\": \"string\",\n \"description\": \"The name of the token\",\n \"internalType\": \"string\",\n \"components\": [\n {\n \"name\": \"_name\",\n \"type\": \"string\",\n \"description\": \"The name of the token\",\n \"internalType\": \"string\",\n \"components\": \"<array>\"\n }\n ],\n \"value\": \"true\"\n }\n ],\n \"outputs\": [\n {\n \"name\": \"_name\",\n \"type\": \"string\",\n \"description\": \"The name of the token\",\n \"internalType\": \"string\",\n \"components\": \"<array>\"\n }\n ],\n \"name\": \"<string>\",\n \"description\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body[
{
"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"
}
}
]{
"message": "<string>",
"code": 123
}