read_contract
Extract and decode blockchain contract states by specifying contract address, method, and expected output types. Ensures accurate data retrieval for nested structures and tuples.
Instructions
Read contract state from a blockchain. important:
In case of a tuple, don't use type tuple, but specify the inner types (found in the source) in order. For nested structs, include the substructs types.
Example:
struct DataTypeA {
DataTypeB b;
//the liquidity index. Expressed in ray
uint128 liquidityIndex;
}
struct DataTypeB {
address token;
}
results in outputs for function with return type DataTypeA (tuple in abi): outputs: [{"type": "address"}, {"type": "uint128"}]
Input Schema
Name | Required | Description | Default |
---|---|---|---|
contract | Yes | The contract address | |
inputs | Yes | Input parameters for the method call | |
method | Yes | The contract method to call | |
network | Yes | The blockchain network (e.g., "ethereum", "base") | |
outputs | Yes | Expected output types for the method call. In case of a tuple, don't use type tuple, but specify the inner types (found in the source) in order. For nested structs, include the substructs types. Example: struct DataTypeA { DataTypeB b; //the liquidity index. Expressed in ray uint128 liquidityIndex; } struct DataTypeB { address token; } results in outputs for function with return type DataTypeA (tuple in abi): outputs: [{"type": "address"}, {"type": "uint128"}] |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"contract": {
"description": "The contract address",
"type": "string"
},
"inputs": {
"description": "Input parameters for the method call",
"items": {
"additionalProperties": false,
"properties": {
"type": {
"description": "The type of the input parameter",
"type": "string"
},
"value": {
"description": "The value of the input parameter"
}
},
"required": [
"type"
],
"type": "object"
},
"type": "array"
},
"method": {
"description": "The contract method to call",
"type": "string"
},
"network": {
"description": "The blockchain network (e.g., \"ethereum\", \"base\")",
"type": "string"
},
"outputs": {
"description": "Expected output types for the method call. \n In case of a tuple, don't use type tuple, but specify the inner types (found in the source) in order. For nested structs, include the substructs types.\n \n Example: \n struct DataTypeA {\n DataTypeB b;\n //the liquidity index. Expressed in ray\n uint128 liquidityIndex;\n }\n \n struct DataTypeB {\n address token;\n }\n \n results in outputs for function with return type DataTypeA (tuple in abi): outputs: [{\"type\": \"address\"}, {\"type\": \"uint128\"}]\n ",
"items": {
"additionalProperties": false,
"properties": {
"components": {
"description": "optional components for tuple types",
"items": {
"$ref": "#/properties/outputs/items"
},
"type": "array"
},
"type": {
"description": "Expected output types for the method call. \n In case of a tuple, don't use type tuple, but specify the inner types (found in the source) in order. For nested structs, include the substructs types.\n \n Example: \n struct DataTypeA {\n DataTypeB b;\n //the liquidity index. Expressed in ray\n uint128 liquidityIndex;\n }\n \n struct DataTypeB {\n address token;\n }\n \n results in outputs for function with return type DataTypeA (tuple in abi): outputs: [{\"type\": \"address\"}, {\"type\": \"uint128\"}]\n ",
"type": "string"
}
},
"required": [
"type"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"network",
"contract",
"method",
"inputs",
"outputs"
],
"type": "object"
}