Call a read function on a deployed contract
Call a read function on a deployed contract by blockchain native asset id and contract address
POST
/
contract_interactions
/
base_asset_id
/
{baseAssetId}
/
contract_address
/
{contractAddress}
/
functions
/
read
TypeScript
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
Response
Read Call Retrieved Successfully
Was this page helpful?
⌘I
TypeScript
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
}