eth_call
curl --request POST \
--url https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300 \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"method": "eth_call",
"id": 1,
"params": [
{
"to": "0xC7846d1bc4d8bcF7c45a7c998b77cE9B3c904365",
"data": "0x1526fe270000000000000000000000000000000000000000000000000000000000000001"
},
"latest"
]
}
'import requests
url = "https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300"
payload = {
"jsonrpc": "2.0",
"method": "eth_call",
"id": 1,
"params": [
{
"to": "0xC7846d1bc4d8bcF7c45a7c998b77cE9B3c904365",
"data": "0x1526fe270000000000000000000000000000000000000000000000000000000000000001"
},
"latest"
]
}
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({
jsonrpc: '2.0',
method: 'eth_call',
id: 1,
params: [
{
to: '0xC7846d1bc4d8bcF7c45a7c998b77cE9B3c904365',
data: '0x1526fe270000000000000000000000000000000000000000000000000000000000000001'
},
'latest'
]
})
};
fetch('https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300', 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://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300",
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([
'jsonrpc' => '2.0',
'method' => 'eth_call',
'id' => 1,
'params' => [
[
'to' => '0xC7846d1bc4d8bcF7c45a7c998b77cE9B3c904365',
'data' => '0x1526fe270000000000000000000000000000000000000000000000000000000000000001'
],
'latest'
]
]),
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://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_call\",\n \"id\": 1,\n \"params\": [\n {\n \"to\": \"0xC7846d1bc4d8bcF7c45a7c998b77cE9B3c904365\",\n \"data\": \"0x1526fe270000000000000000000000000000000000000000000000000000000000000001\"\n },\n \"latest\"\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))
}HttpResponse<String> response = Unirest.post("https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_call\",\n \"id\": 1,\n \"params\": [\n {\n \"to\": \"0xC7846d1bc4d8bcF7c45a7c998b77cE9B3c904365\",\n \"data\": \"0x1526fe270000000000000000000000000000000000000000000000000000000000000001\"\n },\n \"latest\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300")
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 \"jsonrpc\": \"2.0\",\n \"method\": \"eth_call\",\n \"id\": 1,\n \"params\": [\n {\n \"to\": \"0xC7846d1bc4d8bcF7c45a7c998b77cE9B3c904365\",\n \"data\": \"0x1526fe270000000000000000000000000000000000000000000000000000000000000001\"\n },\n \"latest\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "<string>",
"id": 123,
"result": "<string>"
}Optimism node API
eth_call | Optimism
The example is a call to the poolinfo of the Gamma MasterChef contract. eth_call JSON-RPC method available on the Optimism blockchain via Chainstack.
POST
/
efb0a5eccd2caa5135eb54eba6f7f300
eth_call
curl --request POST \
--url https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300 \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"method": "eth_call",
"id": 1,
"params": [
{
"to": "0xC7846d1bc4d8bcF7c45a7c998b77cE9B3c904365",
"data": "0x1526fe270000000000000000000000000000000000000000000000000000000000000001"
},
"latest"
]
}
'import requests
url = "https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300"
payload = {
"jsonrpc": "2.0",
"method": "eth_call",
"id": 1,
"params": [
{
"to": "0xC7846d1bc4d8bcF7c45a7c998b77cE9B3c904365",
"data": "0x1526fe270000000000000000000000000000000000000000000000000000000000000001"
},
"latest"
]
}
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({
jsonrpc: '2.0',
method: 'eth_call',
id: 1,
params: [
{
to: '0xC7846d1bc4d8bcF7c45a7c998b77cE9B3c904365',
data: '0x1526fe270000000000000000000000000000000000000000000000000000000000000001'
},
'latest'
]
})
};
fetch('https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300', 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://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300",
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([
'jsonrpc' => '2.0',
'method' => 'eth_call',
'id' => 1,
'params' => [
[
'to' => '0xC7846d1bc4d8bcF7c45a7c998b77cE9B3c904365',
'data' => '0x1526fe270000000000000000000000000000000000000000000000000000000000000001'
],
'latest'
]
]),
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://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_call\",\n \"id\": 1,\n \"params\": [\n {\n \"to\": \"0xC7846d1bc4d8bcF7c45a7c998b77cE9B3c904365\",\n \"data\": \"0x1526fe270000000000000000000000000000000000000000000000000000000000000001\"\n },\n \"latest\"\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))
}HttpResponse<String> response = Unirest.post("https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"method\": \"eth_call\",\n \"id\": 1,\n \"params\": [\n {\n \"to\": \"0xC7846d1bc4d8bcF7c45a7c998b77cE9B3c904365\",\n \"data\": \"0x1526fe270000000000000000000000000000000000000000000000000000000000000001\"\n },\n \"latest\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://optimism-mainnet.core.chainstack.com/efb0a5eccd2caa5135eb54eba6f7f300")
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 \"jsonrpc\": \"2.0\",\n \"method\": \"eth_call\",\n \"id\": 1,\n \"params\": [\n {\n \"to\": \"0xC7846d1bc4d8bcF7c45a7c998b77cE9B3c904365\",\n \"data\": \"0x1526fe270000000000000000000000000000000000000000000000000000000000000001\"\n },\n \"latest\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "<string>",
"id": 123,
"result": "<string>"
}The example is a call to the
poolinfo of the Gamma MasterChef contract.
Optimism API method eth_call executes a smart contract function call directly and returns the result without requiring a transaction or changing the state on the blockchain. This method is widely used for reading data from smart contracts.
Get your own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.
Parameters
transactionObject— an object containing transaction parameters, including:to— the address of the contract to call.data— the call data, typically including the function signature and parameters.
blockParameter— a string specifying the block number (in hexadecimal) or one of the strings"earliest","latest", or"pending", indicating the blockchain state to use for the call. Most commonly,"latest"is used.
State override (optional)
eth_call accepts an optional third parameter: a state override set that changes account state for this call only. Nothing is written to the chain. The set is an object keyed by account address, and each address can override:
balance— the account balance in wei, hex-encodednonce— the account nonce, hex-encodedcode— the bytecode to run at the addressstate— storage slot values that replace the account’s entire storagestateDiff— storage slot values to change, keeping the rest of the storage
42 at an unused address, then calls that address:
curl --request POST \
--url CHAINSTACK_NODE_URL \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"id": 1,
"method": "eth_call",
"params": [
{ "to": "0x00000000000000000000000000000000c0ffee42", "data": "0x" },
"latest",
{ "0x00000000000000000000000000000000c0ffee42": { "code": "0x602a60005260206000f3" } }
]
}'
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x000000000000000000000000000000000000000000000000000000000000002a"
}
Response
result— the result of the call, encoded as a hexadecimal string. The format of the result depends on the function called.
Use case
Theeth_call method is essential for:
- DApps that need to retrieve state or compute derived values from smart contracts without making a transaction.
- Wallets and interfaces that display contract information, such as token balances or the state of a decentralized finance (DeFi) contract.
- Automated scripts and bots that monitor contract states or conditions on the blockchain.
Last modified on October 1, 2026
Was this page helpful?