.claude/skills/wagmi-write-contract/SKILL.md
Write to contracts and send transactions. Use when executing state-changing contract functions.
npx skillsauth add cyotee/crane wagmi-write-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.
Send transactions to contract functions.
import { writeContract } from '@wagmi/core'
import { config } from './config'
const abi = [
{ type: 'function', name: 'transfer', stateMutability: 'nonpayable',
inputs: [{ name: 'to', type: 'address' }, { name: 'amount', type: 'uint256' }],
outputs: [{ type: 'bool' }]
}
] as const
const hash = await writeContract(config, {
abi,
address: tokenAddress,
functionName: 'transfer',
args: [recipientAddress, 1000000n]
})
Validate transaction before sending:
import { simulateContract, writeContract } from '@wagmi/core'
const { request } = await simulateContract(config, {
abi,
address: tokenAddress,
functionName: 'transfer',
args: [recipient, 1000000n]
})
const hash = await writeContract(config, request)
import { parseGwei, parseEther } from 'viem'
const hash = await writeContract(config, {
abi,
address: tokenAddress,
functionName: 'transfer',
args: [to, amount],
// EIP-1559
maxFeePerGas: parseGwei('20'),
maxPriorityFeePerGas: parseGwei('2'),
// Or legacy
gasPrice: parseGwei('10'),
// Or set gas manually
gas: 50000n,
// Value (for payable functions)
value: parseEther('0.01')
})
import { writeContractSync } from '@wagmi/core'
const receipt = await writeContractSync(config, {
abi,
address: tokenAddress,
functionName: 'transfer',
args: [to, amount]
})
console.log(receipt.status) // 'success' | 'reverted'
console.log(receipt.blockNumber)
const hash = await writeContract(config, {
abi,
address: tokenAddress,
functionName: 'transfer',
args: [to, amount],
account: '0x...' // specific account (must be connected)
})
import { mainnet } from '@wagmi/core/chains'
// Ensure transaction goes to specific chain
const hash = await writeContract(config, {
abi,
address: tokenAddress,
functionName: 'transfer',
args: [to, amount],
chainId: mainnet.id // will throw if wrong chain
})
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".
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.
development
useWriteContract hook for sending transactions. Use when executing state-changing contract functions in React.