Skip to content
Back to skills

Wagmi Read Contract

ASecurity

Read contract data with type-safe ABI. Use when querying smart contract view/pure functions.

  • 9 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 10, 2026
blockchaintypescript

Security analysis

A100/100

Scanned September 10, 2026

npx -y skills add cyotee/indexedex --skill wagmi-read-contract --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Wagmi Read Contract?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Wagmi Read Contract
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/cyotee-wagmi-read-contract/badge)](https://www.skillsdirectory.com/skills/cyotee-wagmi-read-contract)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: wagmi-read-contract
description: Read contract data with type-safe ABI. Use when querying smart contract view/pure functions.
---

# Read Contract

Type-safe contract reads.

## Basic Read

```typescript
import { readContract } from '@wagmi/core'
import { config } from './config'

const abi = [
  { type: 'function', name: 'balanceOf', stateMutability: 'view',
    inputs: [{ name: 'account', type: 'address' }],
    outputs: [{ type: 'uint256' }]
  },
  { type: 'function', name: 'totalSupply', stateMutability: 'view',
    inputs: [],
    outputs: [{ type: 'uint256' }]
  }
] as const

const balance = await readContract(config, {
  abi,
  address: '0x6B175474E89094C44Da98b954EecdEfaE6E286AB',
  functionName: 'balanceOf',
  args: ['0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045']
})
```

## Read with Block Tag

```typescript
const balance = await readContract(config, {
  abi,
  address: tokenAddress,
  functionName: 'balanceOf',
  args: [address],
  blockTag: 'latest'     // 'latest', 'safe', 'finalized', 'earliest', 'pending'
})

// Or specific block
const balanceAtBlock = await readContract(config, {
  abi,
  address: tokenAddress,
  functionName: 'balanceOf',
  args: [address],
  blockNumber: 17829139n
})
```

## Read with Chain ID

```typescript
import { mainnet } from '@wagmi/core/chains'

const balance = await readContract(config, {
  abi,
  address: tokenAddress,
  functionName: 'balanceOf',
  args: [address],
  chainId: mainnet.id
})
```

## Multiple Reads

```typescript
import { readContracts } from '@wagmi/core'

const [balance, supply, decimals] = await readContracts(config, {
  contracts: [
    { abi, address: tokenAddress, functionName: 'balanceOf', args: [address] },
    { abi, address: tokenAddress, functionName: 'totalSupply' },
    { abi, address: tokenAddress, functionName: 'decimals' }
  ]
})
```

## TypeScript Types

With `as const` on ABI, types are inferred:

```typescript
// functionName is type-safe (only functions in abi)
abi: [...] as const

// args are type-safe (inferred from function params)
args: ['0x...']  // ✅ correct
args: [123n]     // ❌ type error for address param

// return type is inferred
const result: bigint = await readContract(config, { ... })
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…