Okto Embedded WalletUsing Embedded Wallet

Read Contract Data On-chain Via Code

Learn how to read data from any smart contract using the Okto SDK.

Methods Overview

MethodsDescription
async readContractDataRead data from any smart contract on supported chains

Read Contract Data

async readContractData(network_name, data) reads data from a smart contract based on the provided parameters.

Parameters

ParameterTypeDescription
network_namestringThe network where the contract is deployed
dataanyNetwork-specific contract interaction details

The structure of data parameter varies based on the network:

// For EVM networks (POLYGON, POLYGON_TESTNET_AMOY, etc.), data should contain:
{
    contractAddress: string;  // The address of the smart contract
    abi: any;                // The ABI of the specific function you want to call
    args: Record<string, any>; // Arguments for the contract function (empty object if no arguments required)
}

Response

Success Response

Field NameTypeDescription
resultPromise<any>Returns the data read from the contract. Type depends on the contract function being called

On this page