.claude/skills/wagmi-react-write/SKILL.md
useWriteContract hook for sending transactions. Use when executing state-changing contract functions in React.
npx skillsauth add cyotee/crane wagmi-react-writeInstall 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.
useWriteContract and related hooks.
import { useWriteContract, useWaitForTransactionReceipt } from 'wagmi'
function Transfer({ tokenAddress }) {
const { writeContract, isPending } = useWriteContract()
const handleTransfer = () => {
writeContract({
abi: [...],
address: tokenAddress,
functionName: 'transfer',
args: [recipient, amount]
})
}
return (
<button onClick={handleTransfer} disabled={isPending}>
{isPending ? 'Confirming...' : 'Transfer'}
</button>
)
}
Validate before sending:
import { useSimulateContract, useWriteContract, useWaitForTransactionReceipt } from 'wagmi'
function Transfer() {
const { data: simData } = useSimulateContract({
abi,
address,
functionName: 'transfer',
args: [to, amount]
})
const { writeContract } = useWriteContract()
return (
<button
onClick={() => writeContract(simData?.request)}
disabled={!simData}
>
Transfer
</button>
)
}
import { useWriteContract, useWaitForTransactionReceipt } from 'wagmi'
function Transfer() {
const { data: hash, writeContract } = useWriteContract()
const { isLoading: isConfirming, isSuccess } = useWaitForTransactionReceipt({
hash
})
const handleTransfer = () => {
writeContract({ abi, address, functionName: 'transfer', args: [to, amount] })
}
return (
<div>
<button onClick={handleTransfer}>Transfer</button>
{isConfirming && <div>Confirming...</div>}
{isSuccess && <div>Confirmed!</div>}
</div>
)
}
const { writeContractAsync } = useWriteContract()
async function handleTransfer() {
try {
const hash = await writeContractAsync({
abi,
address,
functionName: 'transfer',
args: [to, amount]
})
console.log('Transaction hash:', hash)
} catch (error) {
console.error('Transaction failed:', error)
}
}
import { parseEther, parseGwei } from 'viem'
writeContract({
abi,
address,
functionName: 'transfer',
args: [to, amount],
// Gas options
gas: 50000n,
maxFeePerGas: parseGwei('20'),
maxPriorityFeePerGas: parseGwei('2'),
// Value for payable functions
value: parseEther('0.01')
})
import { mainnet } from 'wagmi/chains'
// Will throw if not on correct chain
writeContract({
abi,
address,
functionName: 'transfer',
args: [to, amount],
chainId: mainnet.id
})
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.