Explorer

Read Contract Data

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

Overview

The Okto SDK provides a powerful interface for reading data from smart contracts across supported EVM chains. This Unity-based solution allows developers to interact with any deployed smart contract using a simple, intuitive interface.

For the most up-to-date list of supported chains, block confirmation times, and token support, click here.

Examples

Class Overview

ClassDescription
ReadContractUnity MonoBehaviour class to read data from any smart contract on supported EVM chains

Read Smart Contract Data

ReadSmartContractAsync(string abi, string functionName, string contractAddress, string parameters = "") reads data from a smart contract based on the provided parameters.

Parameters

ParameterTypeDescription
abistringThe JSON ABI of the contract
functionNamestringThe name of the function to call
contractAddressstringThe address of the smart contract
parametersstringOptional comma-separated function parameters

Response

Success Response

Field NameTypeDescription
resultTask<string>Returns the decoded data read from the contract

When passing numeric values, it's recommended to:

  • Use string representation for large numbers to avoid precision loss
  • Ensure values are within the valid range for the specified type
  • Include quotes around all values when passing as parameters

Parameter Formatting Rules:

  1. Multiple parameters should be comma-separated
  2. String values should be properly escaped if they contain special characters
  3. Hex values should include the "0x" prefix
  4. Boolean values can be "true"/"false" (case insensitive)