Call a Chain Method
Use this endpoint to simulate a smart contract method call without changing on-chain state. Ideal for reading balances, metadata, or any other view/pure functions. No gas is consumed, and no wallet is required.
Prerequisites
Section titled “Prerequisites”Before you begin, ensure:
- You’ve correctly encoded your method calldata (
txData
) - You know the target
chainId
Endpoint
Section titled “Endpoint”POST /v2/chain/call
Request Parameters
{ "txData": "0xabcdef...", "chainId": 137, "sentAt": "2025-05-08T12:00:00Z"}
txData
: Encoded calldata for the read-only method (e.g.balanceOf(address)
)chainId
: Numeric ID of the chain to query (e.g. 137 for Polygon)sentAt
: ISO timestamp for submission
Example Request
curl -X POST https://api.fsco.io/v2/chain/call \ -H "Authorization: Bearer $FSCO_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "txData": "0xabcdef...", "chainId": 137, "sentAt": "2025-05-08T12:00:00Z" }'
import axios from 'axios';
const FSCO_API_KEY = process.env.FSCO_API_KEY;
const callChainMethod = async () => { const response = await axios.post( 'https://api.fsco.io/v2/chain/call', { txData: '0xabcdef...', chainId: 137, sentAt: '2025-05-08T12:00:00Z' }, { headers: { Authorization: `Bearer ${FSCO_API_KEY}`, 'Content-Type': 'application/json' } } );
console.log('Chain method called:', response.data);};
callChainMethod();
import requestsimport os
FSCO_API_KEY = os.getenv("FSCO_API_KEY")
headers = { "Authorization": f"Bearer {FSCO_API_KEY}", "Content-Type": "application/json",}
payload = {"txData": "0xabcdef...", "chainId": 137, "sentAt": "2025-05-08T12:00:00Z"}
response = requests.post( "https://api.fsco.io/v2/chain/call", json=payload, headers=headers)
print("Chain method called:", response.json())
using System;using System.Net.Http;using System.Net.Http.Headers;using System.Text;using System.Threading.Tasks;
class Program{ static async Task Main() { var apiKey = Environment.GetEnvironmentVariable("FSCO_API_KEY");
var client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
var json = @"{ ""txData"": ""0xabcdef..."", ""chainId"": 137, ""sentAt"": ""2025-05-08T12:00:00Z"" }"; var content = new StringContent(json, Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.fsco.io/v2/chain/call", content); var responseString = await response.Content.ReadAsStringAsync();
Console.WriteLine("Chain method called: " + responseString); }}
Response
{ "executionId": "12345678-1234-1234-1234-123456789012", "data": "0x00000000000000000000000000000000000000000000000000000000000003e8"}
The response includes:
executionId
: An internal reference for the simulated calldata
: The raw return value of the method in hex format
Next Steps
Section titled “Next Steps”- Execute a Transaction to change on-chain state
- Get Transaction by ID to check transaction status using the FSCO queryId
- Get Transaction by Hash to look up transaction details using the on-chain hash
- Learn more in the Chain module overview
- View the complete Chain API reference