.claude/skills/wagmi-react-read/SKILL.md
useReadContract hook for reading smart contract data. Use when querying contract view/pure functions in React.
npx skillsauth add cyotee/crane wagmi-react-readInstall 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.
useReadContract and related hooks.
import { useReadContract } from 'wagmi'
const abi = [
{ type: 'function', name: 'balanceOf', stateMutability: 'view',
inputs: [{ name: 'account', type: 'address' }],
outputs: [{ name: 'balance', type: 'uint256' }]
},
{ type: 'function', name: 'decimals', stateMutability: 'view',
inputs: [],
outputs: [{ name: '', type: 'uint8' }]
}
] as const
function TokenBalance({ address, tokenAddress }) {
const { data, isError, isLoading } = useReadContract({
abi,
address: tokenAddress,
functionName: 'balanceOf',
args: [address]
})
if (isLoading) return <div>Loading...</div>
if (isError) return <div>Error</div>
return <div>Balance: {data?.toString()}</div>
}
// Auto-refetch when block changes
const { data } = useReadContract({
abi,
address,
functionName: 'balanceOf',
args: [address],
watch: true
})
import { useReadContracts } from 'wagmi'
const { data } = useReadContracts({
contracts: [
{ abi, address: tokenA, functionName: 'balanceOf', args: [user] },
{ abi, address: tokenB, functionName: 'balanceOf', args: [user] },
{ abi, address: tokenC, functionName: 'balanceOf', args: [user] },
]
})
const [balanceA, balanceB, balanceC] = data ?? []
const { data } = useReadContract({
abi,
address,
functionName: 'balanceOf',
args: [address],
query: {
enabled: !!address && address !== '0x...', // conditional
staleTime: 60 * 1000, // cache for 1 minute
refetchInterval: 10000, // poll every 10 seconds
}
})
const { data } = useReadContract({
abi,
address,
functionName: 'balanceOf',
args: [address],
blockTag: 'latest' // 'latest', 'safe', 'finalized'
})
const { data, refetch, isRefetching } = useReadContract({ ... })
<button onClick={() => refetch()} disabled={isRefetching}>
Refresh
</button>
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.
data-ai
Read contract data with type-safe ABI. Use when querying smart contract view/pure functions.