Call Contract
Returns a result from EVM execution such as cost-free execution of read-only smart contract queries, gas estimation, and transient simulation of read-write operations. If estimate field is set to true gas estimation is executed. Currently we support only latest block.
The table below defines the restrictions and support for the endpoint
| Estimate | Operation Type | Mirror Node Version |
|---|---|---|
| false | static contract state reads for non precompile functions | 0.78+ |
| static contract state reads for precompile functions except allowance/isApprovedForAll | 0.78+ | |
| static contract state reads for precompile functions with allowance | 0.79+ | |
| static contract state reads for precompile functions with isApprovedForAll | 0.81+ | |
| non-static contract state reads for non precompile functions | 0.83+ | |
| non-static contract state reads for precompile read only functions | 0.83+ | |
| true | non-static contract state reads and modifications for non precompile functions except lazy account creation | 0.83+ |
| non-static contract state reads and modifications for associate precompile functions | 0.83+ | |
| non-static contract state reads and modifications for non precompile functions with lazy account creation | 0.84+ | |
| non-static contract state reads and modifications for precompile functions except associate | Not supported |
The operations types which are not currently supported should return 501 error status.
curl --request POST \
--url https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/call \
--header 'Content-Type: application/json' \
--data '
{
"to": "0x00000000000000000000000000000000000003f4",
"block": "latest",
"data": "0x0198489200000000000000000000000000000000000000000000000000000000000003ee",
"estimate": true,
"from": "00000000000000000000000000000000000004e2",
"gas": 120000000,
"gasPrice": 100000000,
"value": 0
}
'import requests
url = "https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/call"
payload = {
"to": "0x00000000000000000000000000000000000003f4",
"block": "latest",
"data": "0x0198489200000000000000000000000000000000000000000000000000000000000003ee",
"estimate": True,
"from": "00000000000000000000000000000000000004e2",
"gas": 120000000,
"gasPrice": 100000000,
"value": 0
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
to: '0x00000000000000000000000000000000000003f4',
block: 'latest',
data: '0x0198489200000000000000000000000000000000000000000000000000000000000003ee',
estimate: true,
from: '00000000000000000000000000000000000004e2',
gas: 120000000,
gasPrice: 100000000,
value: 0
})
};
fetch('https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/call', 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://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/call",
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([
'to' => '0x00000000000000000000000000000000000003f4',
'block' => 'latest',
'data' => '0x0198489200000000000000000000000000000000000000000000000000000000000003ee',
'estimate' => true,
'from' => '00000000000000000000000000000000000004e2',
'gas' => 120000000,
'gasPrice' => 100000000,
'value' => 0
]),
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://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/call"
payload := strings.NewReader("{\n \"to\": \"0x00000000000000000000000000000000000003f4\",\n \"block\": \"latest\",\n \"data\": \"0x0198489200000000000000000000000000000000000000000000000000000000000003ee\",\n \"estimate\": true,\n \"from\": \"00000000000000000000000000000000000004e2\",\n \"gas\": 120000000,\n \"gasPrice\": 100000000,\n \"value\": 0\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))
}HttpResponse<String> response = Unirest.post("https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/call")
.header("Content-Type", "application/json")
.body("{\n \"to\": \"0x00000000000000000000000000000000000003f4\",\n \"block\": \"latest\",\n \"data\": \"0x0198489200000000000000000000000000000000000000000000000000000000000003ee\",\n \"estimate\": true,\n \"from\": \"00000000000000000000000000000000000004e2\",\n \"gas\": 120000000,\n \"gasPrice\": 100000000,\n \"value\": 0\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/call")
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 \"to\": \"0x00000000000000000000000000000000000003f4\",\n \"block\": \"latest\",\n \"data\": \"0x0198489200000000000000000000000000000000000000000000000000000000000003ee\",\n \"estimate\": true,\n \"from\": \"00000000000000000000000000000000000004e2\",\n \"gas\": 120000000,\n \"gasPrice\": 100000000,\n \"value\": 0\n}"
response = http.request(request)
puts response.read_body{
"result": "0x94c4d54535f6e616d6500"
}{
"_status": {
"messages": [
{
"data": "0x3000",
"detail": "Generic detailed error message",
"message": "Generic error message"
}
]
}
}{
"_status": {
"messages": [
{
"data": "0x3000",
"detail": "Generic detailed error message",
"message": "Generic error message"
}
]
}
}{
"_status": {
"messages": [
{
"data": "0x3000",
"detail": "Generic detailed error message",
"message": "Generic error message"
}
]
}
}{
"_status": {
"messages": [
{
"data": "0x3000",
"detail": "Generic detailed error message",
"message": "Generic error message"
}
]
}
}{
"_status": {
"messages": [
{
"data": "0x3000",
"detail": "Generic detailed error message",
"message": "Generic error message"
}
]
}
}{
"_status": {
"messages": [
{
"data": "0x3000",
"detail": "Generic detailed error message",
"message": "Generic error message"
}
]
}
}100 Compute Units.
Body
The 20-byte hexadecimal EVM address the transaction is directed to.
40 - 42^(0x)?[A-Fa-f0-9]{40}$Hexadecimal block number or the string "latest", "pending", "earliest". Defaults to "latest".
^((0x)?[0-9a-fA-F]+|(earliest|pending|latest))$"latest"
Hexadecimal method signature and encoded parameters.
12288^(0x)?[0-9a-fA-F]+$Whether gas estimation is called. Defaults to false.
true
The 20-byte hexadecimal EVM address the transaction is sent from.
40 - 42^(0x)?[A-Fa-f0-9]{40}$Gas provided for the transaction execution. Defaults to 120000000.
x >= 0120000000
Gas price used for each paid gas.
x >= 0100000000
Value sent with this transaction. Defaults to 0.
x >= 00
Response
OK
Result in hexadecimal from executed contract call.
^0x[0-9a-fA-F]+$curl --request POST \
--url https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/call \
--header 'Content-Type: application/json' \
--data '
{
"to": "0x00000000000000000000000000000000000003f4",
"block": "latest",
"data": "0x0198489200000000000000000000000000000000000000000000000000000000000003ee",
"estimate": true,
"from": "00000000000000000000000000000000000004e2",
"gas": 120000000,
"gasPrice": 100000000,
"value": 0
}
'import requests
url = "https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/call"
payload = {
"to": "0x00000000000000000000000000000000000003f4",
"block": "latest",
"data": "0x0198489200000000000000000000000000000000000000000000000000000000000003ee",
"estimate": True,
"from": "00000000000000000000000000000000000004e2",
"gas": 120000000,
"gasPrice": 100000000,
"value": 0
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
to: '0x00000000000000000000000000000000000003f4',
block: 'latest',
data: '0x0198489200000000000000000000000000000000000000000000000000000000000003ee',
estimate: true,
from: '00000000000000000000000000000000000004e2',
gas: 120000000,
gasPrice: 100000000,
value: 0
})
};
fetch('https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/call', 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://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/call",
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([
'to' => '0x00000000000000000000000000000000000003f4',
'block' => 'latest',
'data' => '0x0198489200000000000000000000000000000000000000000000000000000000000003ee',
'estimate' => true,
'from' => '00000000000000000000000000000000000004e2',
'gas' => 120000000,
'gasPrice' => 100000000,
'value' => 0
]),
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://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/call"
payload := strings.NewReader("{\n \"to\": \"0x00000000000000000000000000000000000003f4\",\n \"block\": \"latest\",\n \"data\": \"0x0198489200000000000000000000000000000000000000000000000000000000000003ee\",\n \"estimate\": true,\n \"from\": \"00000000000000000000000000000000000004e2\",\n \"gas\": 120000000,\n \"gasPrice\": 100000000,\n \"value\": 0\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))
}HttpResponse<String> response = Unirest.post("https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/call")
.header("Content-Type", "application/json")
.body("{\n \"to\": \"0x00000000000000000000000000000000000003f4\",\n \"block\": \"latest\",\n \"data\": \"0x0198489200000000000000000000000000000000000000000000000000000000000003ee\",\n \"estimate\": true,\n \"from\": \"00000000000000000000000000000000000004e2\",\n \"gas\": 120000000,\n \"gasPrice\": 100000000,\n \"value\": 0\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{network}.hedera.validationcloud.io/v1/{API_KEY}/api/v1/contracts/call")
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 \"to\": \"0x00000000000000000000000000000000000003f4\",\n \"block\": \"latest\",\n \"data\": \"0x0198489200000000000000000000000000000000000000000000000000000000000003ee\",\n \"estimate\": true,\n \"from\": \"00000000000000000000000000000000000004e2\",\n \"gas\": 120000000,\n \"gasPrice\": 100000000,\n \"value\": 0\n}"
response = http.request(request)
puts response.read_body{
"result": "0x94c4d54535f6e616d6500"
}{
"_status": {
"messages": [
{
"data": "0x3000",
"detail": "Generic detailed error message",
"message": "Generic error message"
}
]
}
}{
"_status": {
"messages": [
{
"data": "0x3000",
"detail": "Generic detailed error message",
"message": "Generic error message"
}
]
}
}{
"_status": {
"messages": [
{
"data": "0x3000",
"detail": "Generic detailed error message",
"message": "Generic error message"
}
]
}
}{
"_status": {
"messages": [
{
"data": "0x3000",
"detail": "Generic detailed error message",
"message": "Generic error message"
}
]
}
}{
"_status": {
"messages": [
{
"data": "0x3000",
"detail": "Generic detailed error message",
"message": "Generic error message"
}
]
}
}{
"_status": {
"messages": [
{
"data": "0x3000",
"detail": "Generic detailed error message",
"message": "Generic error message"
}
]
}
}