# read_contract_state

Read the current on-chain value of a view/pure function. Fetches from the chain (cached 60s) and returns the decoded output. Accepts slug or chain+address.

Agent View of the PolicyLayer registry record for `read_contract_state`. HTML page: https://policylayer.com/tools/defi-io-smartcontract/read-contract-state

## Facts

- Tool: `read_contract_state`
- Server: Smarts Md (`defi-io/smartcontract`) — https://policylayer.com/tools/defi-io-smartcontract.md
- Homepage: https://github.com/defi-io/smartcontract
- Risk category: Read (Low risk)
- Registry record: grade B, identity unverified
- Server rate-limited: no
- Parameters: 5
- Recommended policy verdict: Allowed

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `args` | array | no | Positional arguments for the function, in ABI order. Addresses as 0x hex strings, integers as integers. Default: [] |
| `slug` | string | no | Curated slug like 'uni-eth'. Alternative to chain+address. |
| `chain` | string | no | Chain slug: eth, base, arbitrum, optimism, or polygon. Required unless `slug` is given. |
| `address` | string | no | The 0x-prefixed contract address. Required unless `slug` is given. |
| `function_name` | string | no | ABI function name, e.g. 'totalSupply' or 'balanceOf'. |

Parameters from the server's own tool schema.

## Example call (MCP tools/call, JSON-RPC 2.0)

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "read_contract_state",
    "arguments": {}
  }
}
```

## Why read_contract_state is rated Low

This tool retrieves data from smart contracts without any capability to modify, execute transactions, or trigger state changes. View and pure functions are read-only by definition in Solidity. The 60-second caching and decoding of outputs are standard for blockchain data queries. No financial transactions, code execution, or data destruction are possible.

From the tool's own definition: "Tool description explicitly states 'Read the current on-chain value' and 'returns the decoded output'. The name 'read_contract_state' and function signature indicate query-only access to view/pure functions with no state modification."

## Use case

AI agents call read_contract_state to retrieve information from Smarts Md without modifying anything. It is typically the context-gathering step in research, monitoring, and reporting workflows, before the agent takes action elsewhere.

## Recommended policy (PolicyLayer)

Verdict: **Allowed**. Enforced by the PolicyLayer MCP gateway (https://policylayer.com/mcp-gateway) before a call reaches Smarts Md:

```json
{
  "version": "1",
  "default": "deny",
  "tools": {
    "read_contract_state": {}
  }
}
```

## Other tools on Smarts Md (4)

- `get_contract_info` — Read — https://policylayer.com/tools/defi-io-smartcontract/get-contract-info.md
- `get_erc20_info` — Read — https://policylayer.com/tools/defi-io-smartcontract/get-erc20-info.md
- `get_uniswap_v3_pool` — Read — https://policylayer.com/tools/defi-io-smartcontract/get-uniswap-v3-pool.md
- `inspect_address` — Read — https://policylayer.com/tools/defi-io-smartcontract/inspect-address.md

## For agents

This record is a snapshot. Live verdicts and the full registry:

- Check every server in your MCP config at once: `npx -y policylayer stack`
- Vet a server before you add it: install the mcp-precheck skill — `npx skills add https://policylayer.com` (skill text: https://policylayer.com/skill.md)
- Query the registry over MCP: endpoint `https://api.policylayer.com/mcp` — tools `check_mcp_server`, `check_mcp_stack`, `check_tool`, `search_registry`, `get_change_events`

---

Source: the PolicyLayer MCP registry — one continuously verified record per MCP server. Full record: https://policylayer.com/registry?q=defi-io-smartcontract · API: https://policylayer.com/registry/api · Policy library: https://policylayer.com/policies/defi-io-smartcontract
