read_contract
Query smart contract functions directly to retrieve decoded state data. Use the tool by specifying chain ID, contract address, ABI, and function name to obtain specific contract information programmatically.
Instructions
Calls a smart contract function (view/pure, or non-view/pure simulated via eth_call) and returns the
decoded result.
This tool provides a direct way to query the state of a smart contract.
Example:
To check the USDT balance of an address on Ethereum Mainnet, you would use the following arguments:
{
"tool_name": "read_contract",
"params": {
"chain_id": "1",
"address": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"abi": {
"constant": true,
"inputs": [{"name": "_owner", "type": "address"}],
"name": "balanceOf",
"outputs": [{"name": "balance", "type": "uint256"}],
"payable": false,
"stateMutability": "view",
"type": "function"
},
"function_name": "balanceOf",
"args": ["0xF977814e90dA44bFA03b6295A0616a897441aceC"]
}
}
Input Schema
Name | Required | Description | Default |
---|---|---|---|
abi | Yes | The JSON ABI for the specific function being called. This should be a dictionary that defines the function's name, inputs, and outputs. The function ABI can be obtained using the `get_contract_abi` tool. | |
address | Yes | Smart contract address | |
args | No | A JSON array of arguments (not a string). Example: ["0xabc..."] is correct; "[\"0xabc...\"]" is incorrect. Order and types must match ABI inputs. Addresses: use 0x-prefixed strings; Numbers: use integers (not quoted); Bytes: keep as 0x-hex strings. If no arguments, pass [] or omit this field. | |
block | No | The block identifier to read the contract state from. Can be a block number (e.g., 19000000) or a string tag (e.g., 'latest'). Defaults to 'latest'. | latest |
chain_id | Yes | The ID of the blockchain | |
function_name | Yes | The symbolic name of the function to be called. This must match the `name` field in the provided ABI. |
Input Schema (JSON Schema)
{
"properties": {
"abi": {
"additionalProperties": true,
"description": "The JSON ABI for the specific function being called. This should be a dictionary that defines the function's name, inputs, and outputs. The function ABI can be obtained using the `get_contract_abi` tool.",
"title": "Abi",
"type": "object"
},
"address": {
"description": "Smart contract address",
"title": "Address",
"type": "string"
},
"args": {
"anyOf": [
{
"items": {},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "A JSON array of arguments (not a string). Example: [\"0xabc...\"] is correct; \"[\\\"0xabc...\\\"]\" is incorrect. Order and types must match ABI inputs. Addresses: use 0x-prefixed strings; Numbers: use integers (not quoted); Bytes: keep as 0x-hex strings. If no arguments, pass [] or omit this field.",
"title": "Args"
},
"block": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer"
}
],
"default": "latest",
"description": "The block identifier to read the contract state from. Can be a block number (e.g., 19000000) or a string tag (e.g., 'latest'). Defaults to 'latest'.",
"title": "Block"
},
"chain_id": {
"description": "The ID of the blockchain",
"title": "Chain Id",
"type": "string"
},
"function_name": {
"description": "The symbolic name of the function to be called. This must match the `name` field in the provided ABI.",
"title": "Function Name",
"type": "string"
}
},
"required": [
"chain_id",
"address",
"abi",
"function_name"
],
"title": "read_contractArguments",
"type": "object"
}