Skip to content
Back to skills

Wagmi Write Contract

ASecurity

Write to contracts and send transactions. Use when executing state-changing contract functions.

  • 9 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 10, 2026
developmenttypescriptgo

Security analysis

A100/100

Scanned September 10, 2026

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

Installs into .claude/skills of the current project.

Are you the author of Wagmi Write Contract?

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

Security grade badge for Wagmi Write Contract
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/cyotee-wagmi-write-contract/badge)](https://www.skillsdirectory.com/skills/cyotee-wagmi-write-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-write-contract
description: Write to contracts and send transactions. Use when executing state-changing contract functions.
---

# Write Contract

Send transactions to contract functions.

## Basic Write

```typescript
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]
})
```

## Simulate Before Write

Validate transaction before sending:

```typescript
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)
```

## With Gas Settings

```typescript
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')
})
```

## writeContractSync (Wait for Receipt)

```typescript
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)
```

## With Account

```typescript
const hash = await writeContract(config, {
  abi,
  address: tokenAddress,
  functionName: 'transfer',
  args: [to, amount],
  account: '0x...'  // specific account (must be connected)
})
```

## Chain Validation

```typescript
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
})
```

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…