Call a write function on a deployed contract
Call a write function on a deployed contract by blockchain native asset id and contract address. This creates an onchain transaction, thus it is an async operation. It returns a transaction id that can be polled for status check
POST
/
contract_interactions
/
base_asset_id
/
{baseAssetId}
/
contract_address
/
{contractAddress}
/
functions
/
write
TypeScript
const response: Promise<FireblocksResponse<WriteCallFunctionResponseDto>> = fireblocks.contractInteractions.writeCallFunction(contractInteractionsApiWriteCallFunctionRequest);CompletableFuture<ApiResponse<WriteCallFunctionResponseDto>> response = fireblocks.contractInteractions().writeCallFunction(writeCallFunctionDto, contractAddress, baseAssetId, idempotencyKey);response = fireblocks.contract_interactions.write_call_function(write_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/write \
--header 'Content-Type: application/json' \
--data '
{
"vaultAccountId": "0",
"abiFunction": {
"stateMutability": "nonpayable",
"type": "function",
"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>"
},
"amount": "12.345",
"feeLevel": "MEDIUM",
"fee": "2000",
"note": "<string>",
"useGasless": false,
"externalId": "0192e4f5-924e-7bb9-8e5b-c748270feb38"
}
'const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
vaultAccountId: '0',
abiFunction: {
stateMutability: 'nonpayable',
type: 'function',
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>'
},
amount: '12.345',
feeLevel: 'MEDIUM',
fee: '2000',
note: '<string>',
useGasless: false,
externalId: '0192e4f5-924e-7bb9-8e5b-c748270feb38'
})
};
fetch('https://api.fireblocks.io/v1/contract_interactions/base_asset_id/{baseAssetId}/contract_address/{contractAddress}/functions/write', 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/write",
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([
'vaultAccountId' => '0',
'abiFunction' => [
'stateMutability' => 'nonpayable',
'type' => 'function',
'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>'
],
'amount' => '12.345',
'feeLevel' => 'MEDIUM',
'fee' => '2000',
'note' => '<string>',
'useGasless' => false,
'externalId' => '0192e4f5-924e-7bb9-8e5b-c748270feb38'
]),
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/write"
payload := strings.NewReader("{\n \"vaultAccountId\": \"0\",\n \"abiFunction\": {\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\",\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 \"amount\": \"12.345\",\n \"feeLevel\": \"MEDIUM\",\n \"fee\": \"2000\",\n \"note\": \"<string>\",\n \"useGasless\": false,\n \"externalId\": \"0192e4f5-924e-7bb9-8e5b-c748270feb38\"\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/write")
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 \"vaultAccountId\": \"0\",\n \"abiFunction\": {\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\",\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 \"amount\": \"12.345\",\n \"feeLevel\": \"MEDIUM\",\n \"fee\": \"2000\",\n \"note\": \"<string>\",\n \"useGasless\": false,\n \"externalId\": \"0192e4f5-924e-7bb9-8e5b-c748270feb38\"\n}"
response = http.request(request)
puts response.read_body{
"txId": "<string>"
}{
"message": "<string>",
"code": 123
}Headers
Body
application/json
Was this page helpful?
⌘I
TypeScript
const response: Promise<FireblocksResponse<WriteCallFunctionResponseDto>> = fireblocks.contractInteractions.writeCallFunction(contractInteractionsApiWriteCallFunctionRequest);CompletableFuture<ApiResponse<WriteCallFunctionResponseDto>> response = fireblocks.contractInteractions().writeCallFunction(writeCallFunctionDto, contractAddress, baseAssetId, idempotencyKey);response = fireblocks.contract_interactions.write_call_function(write_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/write \
--header 'Content-Type: application/json' \
--data '
{
"vaultAccountId": "0",
"abiFunction": {
"stateMutability": "nonpayable",
"type": "function",
"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>"
},
"amount": "12.345",
"feeLevel": "MEDIUM",
"fee": "2000",
"note": "<string>",
"useGasless": false,
"externalId": "0192e4f5-924e-7bb9-8e5b-c748270feb38"
}
'const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
vaultAccountId: '0',
abiFunction: {
stateMutability: 'nonpayable',
type: 'function',
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>'
},
amount: '12.345',
feeLevel: 'MEDIUM',
fee: '2000',
note: '<string>',
useGasless: false,
externalId: '0192e4f5-924e-7bb9-8e5b-c748270feb38'
})
};
fetch('https://api.fireblocks.io/v1/contract_interactions/base_asset_id/{baseAssetId}/contract_address/{contractAddress}/functions/write', 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/write",
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([
'vaultAccountId' => '0',
'abiFunction' => [
'stateMutability' => 'nonpayable',
'type' => 'function',
'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>'
],
'amount' => '12.345',
'feeLevel' => 'MEDIUM',
'fee' => '2000',
'note' => '<string>',
'useGasless' => false,
'externalId' => '0192e4f5-924e-7bb9-8e5b-c748270feb38'
]),
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/write"
payload := strings.NewReader("{\n \"vaultAccountId\": \"0\",\n \"abiFunction\": {\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\",\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 \"amount\": \"12.345\",\n \"feeLevel\": \"MEDIUM\",\n \"fee\": \"2000\",\n \"note\": \"<string>\",\n \"useGasless\": false,\n \"externalId\": \"0192e4f5-924e-7bb9-8e5b-c748270feb38\"\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/write")
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 \"vaultAccountId\": \"0\",\n \"abiFunction\": {\n \"stateMutability\": \"nonpayable\",\n \"type\": \"function\",\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 \"amount\": \"12.345\",\n \"feeLevel\": \"MEDIUM\",\n \"fee\": \"2000\",\n \"note\": \"<string>\",\n \"useGasless\": false,\n \"externalId\": \"0192e4f5-924e-7bb9-8e5b-c748270feb38\"\n}"
response = http.request(request)
puts response.read_body{
"txId": "<string>"
}{
"message": "<string>",
"code": 123
}