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
Class | Description |
---|---|
ReadContract | Unity 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
Parameter | Type | Description |
---|---|---|
abi | string | The JSON ABI of the contract |
functionName | string | The name of the function to call |
contractAddress | string | The address of the smart contract |
parameters | string | Optional comma-separated function parameters |
Response
Success Response
Field Name | Type | Description |
---|---|---|
result | Task<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:
- Multiple parameters should be comma-separated
- String values should be properly escaped if they contain special characters
- Hex values should include the "0x" prefix
- Boolean values can be "true"/"false" (case insensitive)