Skip to content

Learn: Cheat sheet — viem + wagmi common patterns (slice of #33) #45

@PetarStoev02

Description

@PetarStoev02

Context

This is a focused slice of #33 (Cheat sheets). viem and wagmi are the modern EVM frontend stack — but the docs are large and developers waste time hunting the same 10 patterns. A single cheat sheet collects them.

What to build

Add cheat-sheets/viem-wagmi-patterns.md with concise, copy-pasteable snippets for:

viem core:

  • Create a public client (read) and a wallet client (write)
  • Read a contract (readContract)
  • Write to a contract (writeContract + waitForTransactionReceipt)
  • Watch events (watchContractEvent)
  • Get the current chain, switch chains
  • Encode/decode function data

wagmi hooks:

  • useAccount, useConnect, useDisconnect
  • useReadContract, useWriteContract
  • useWatchContractEvent
  • useSwitchChain, useBalance

Each snippet should be a self-contained TypeScript code block, not a full app. Order from "most-used" to "less-used".

Acceptance criteria

  • cheat-sheets/viem-wagmi-patterns.md exists and renders cleanly
  • Covers at least 6 viem patterns and 6 wagmi hooks
  • Every snippet is valid TypeScript and uses current API versions
  • At least one "gotcha" called out (e.g., reading after a write, RPC rate limits)
  • Linked from the cheat-sheets index when one exists

Pointers

Complexity

🟢 Good first issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or requestgood first issueGood for newcomers

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions