.claude/skills/wagmi-read-contract/SKILL.md
Read contract data with type-safe ABI. Use when querying smart contract view/pure functions.
npx skillsauth add cyotee/crane wagmi-read-contractInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Type-safe contract reads.
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']
})
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
})
import { mainnet } from '@wagmi/core/chains'
const balance = await readContract(config, {
abi,
address: tokenAddress,
functionName: 'balanceOf',
args: [address],
chainId: mainnet.id
})
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' }
]
})
With as const on ABI, types are inferred:
// 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, { ... })
development
Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".
documentation
Write to contracts and send transactions. Use when executing state-changing contract functions.
development
HTTP and WebSocket transports for blockchain connectivity. Use when configuring network connections.
development
useWriteContract hook for sending transactions. Use when executing state-changing contract functions in React.