Agent skill

Dapp Frontend Patterns

by ccashwell in ccashwell/evm-cortex

A skill your agent uses when building dApp frontends with wagmi v2 and viem.

MITAuto-check passedFrontend & Design

Install Dapp Frontend Patterns

skills CLI
$ npx skills add ccashwell/evm-cortex --skill dapp-frontend-patterns -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install ccashwell/evm-cortex dapp-frontend-patterns --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/ccashwell/evm-cortex.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/dapp-frontend-patterns .claude/skills/dapp-frontend-patterns && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
dapp-frontend-patterns
GitHub stars
131
Token cost
~1.9k tokens
SKILL.md length
112 words
Files
1
Skills in repo
89
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses when building dApp frontends with wagmi v2 and viem.

  • Building dApp frontends with wagmi v2 and viem
  • SKILL.md covers Stack Overview, Project Setup, Wagmi Config and Provider Setup, plus 7 more sections
  • Calls npm
  • Tasks that involve Smart contracts

What it does

Dapp Frontend Patterns is an agent skill from ccashwell/evm-cortex. Use when building dApp frontends with wagmi v2 and viem. Covers useReadContract, useWriteContract, useSimulateContract, useWaitForTransactionReceipt, wallet connection (RainbowKit), chain switching, and ENS resolution.

Its SKILL.md is about 1.9k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Frontend & Design, covering Smart contracts. It works with viem and wagmi. The repository describes itself as: Ethereum protocol engineering squad for AI coding assistants. The licence is MIT.

When your agent uses it

  • Building dApp frontends with wagmi v2 and viem
  • Tasks that involve Smart contracts

Example prompts

  • “/dapp-frontend-patterns”

Requirements

  • Node.js

What it can do on your machine

Read from SKILL.md and the folder at commit f8f3301. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use npm, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Dapp Frontend Patterns loads about 1.9k tokens when it runs. Until then it costs about 60 tokens; SKILL.md has 112 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~60
When it runs · the whole SKILL.md, loaded when a task matches
~1.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from ccashwell/evm-cortex at commit f8f3301, republished under its MIT licence (© ccashwell). 112 words, ~1,928 tokens.

Download SKILL.mdSave it as .claude/skills/dapp-frontend-patterns/SKILL.md (or your agent's skills folder).
name
dapp-frontend-patterns
description
Use when building dApp frontends with wagmi v2 and viem. Covers useReadContract, useWriteContract, useSimulateContract, useWaitForTransactionReceipt, wallet connection (RainbowKit), chain switching, and ENS resolution.

dApp Frontend Patterns

Stack Overview

  • viem: Low-level TypeScript library for Ethereum (replaces ethers.js)
  • wagmi v2: React hooks for Ethereum (built on viem + TanStack Query)
  • RainbowKit: Wallet connection UI component

Project Setup

bash
npm create wagmi@latest my-dapp
# Select: Next.js, RainbowKit

# Or add to existing project:
npm install wagmi viem @tanstack/react-query @rainbow-me/rainbowkit

Wagmi Config

typescript
import { http, createConfig } from 'wagmi';
import { base, mainnet, optimism } from 'wagmi/chains';
import { getDefaultConfig } from '@rainbow-me/rainbowkit';

export const config = getDefaultConfig({
  appName: 'My dApp',
  projectId: process.env.NEXT_PUBLIC_WC_PROJECT_ID!, // WalletConnect
  chains: [base, mainnet, optimism],
  transports: {
    [base.id]: http(process.env.NEXT_PUBLIC_BASE_RPC),
    [mainnet.id]: http(process.env.NEXT_PUBLIC_MAINNET_RPC),
    [optimism.id]: http(process.env.NEXT_PUBLIC_OP_RPC),
  },
});

Provider Setup

tsx
'use client';

import { WagmiProvider } from 'wagmi';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { RainbowKitProvider, darkTheme } from '@rainbow-me/rainbowkit';
import { config } from './config';
import '@rainbow-me/rainbowkit/styles.css';

const queryClient = new QueryClient();

export function Providers({ children }: { children: React.ReactNode }) {
  return (
    <WagmiProvider config={config}>
      <QueryClientProvider client={queryClient}>
        <RainbowKitProvider theme={darkTheme()}>
          {children}
        </RainbowKitProvider>
      </QueryClientProvider>
    </WagmiProvider>
  );
}

Reading Contract Data

tsx
import { useReadContract, useReadContracts } from 'wagmi';
import { formatEther, formatUnits } from 'viem';

const tokenAbi = [
  { name: 'balanceOf', type: 'function', stateMutability: 'view',
    inputs: [{ name: 'account', type: 'address' }],
    outputs: [{ name: '', type: 'uint256' }] },
  { name: 'decimals', type: 'function', stateMutability: 'view',
    inputs: [], outputs: [{ name: '', type: 'uint8' }] },
  { name: 'symbol', type: 'function', stateMutability: 'view',
    inputs: [], outputs: [{ name: '', type: 'string' }] },
] as const;

function TokenBalance({ address, token }: { address: `0x${string}`; token: `0x${string}` }) {
  const { data: balance, isLoading } = useReadContract({
    address: token,
    abi: tokenAbi,
    functionName: 'balanceOf',
    args: [address],
  });

  // Batch multiple reads in one call
  const { data: tokenInfo } = useReadContracts({
    contracts: [
      { address: token, abi: tokenAbi, functionName: 'symbol' },
      { address: token, abi: tokenAbi, functionName: 'decimals' },
    ],
  });

  if (isLoading) return <span>Loading...</span>;

  const symbol = tokenInfo?.[0]?.result ?? '';
  const decimals = tokenInfo?.[1]?.result ?? 18;

  return (
    <span>
      {balance != null ? formatUnits(balance, decimals) : '0'} {symbol}
    </span>
  );
}

Writing to Contracts (Simulate + Write + Wait)

tsx
import { useSimulateContract, useWriteContract, useWaitForTransactionReceipt } from 'wagmi';
import { parseEther } from 'viem';

function DepositButton({ amount }: { amount: string }) {
  // 1. Simulate (dry run) to check for revert
  const { data: simData, error: simError } = useSimulateContract({
    address: '0xVault',
    abi: vaultAbi,
    functionName: 'deposit',
    args: [parseEther(amount)],
  });

  // 2. Write (send transaction)
  const { writeContract, data: txHash, isPending } = useWriteContract();

  // 3. Wait for confirmation
  const { isLoading: isConfirming, isSuccess } = useWaitForTransactionReceipt({
    hash: txHash,
  });

  return (
    <div>
      {simError && <p>Error: {simError.message}</p>}
      <button
        disabled={!simData?.request || isPending || isConfirming}
        onClick={() => writeContract(simData!.request)}
      >
        {isPending ? 'Signing...' : isConfirming ? 'Confirming...' : 'Deposit'}
      </button>
      {isSuccess && <p>Deposit confirmed!</p>}
    </div>
  );
}

Approval + Action Pattern

tsx
function ApproveAndDeposit({ token, vault, amount }: Props) {
  const { address } = useAccount();

  const { data: allowance } = useReadContract({
    address: token,
    abi: erc20Abi,
    functionName: 'allowance',
    args: [address!, vault],
  });

  const needsApproval = allowance != null && allowance < amount;

  const { data: approveSim } = useSimulateContract({
    address: token,
    abi: erc20Abi,
    functionName: 'approve',
    args: [vault, amount],
    query: { enabled: needsApproval },
  });

  const { data: depositSim } = useSimulateContract({
    address: vault,
    abi: vaultAbi,
    functionName: 'deposit',
    args: [amount],
    query: { enabled: !needsApproval },
  });

  const { writeContract, data: txHash } = useWriteContract();
  const { isSuccess } = useWaitForTransactionReceipt({ hash: txHash });

  if (needsApproval) {
    return (
      <button
        disabled={!approveSim?.request}
        onClick={() => writeContract(approveSim!.request)}
      >
        Approve
      </button>
    );
  }

  return (
    <button
      disabled={!depositSim?.request}
      onClick={() => writeContract(depositSim!.request)}
    >
      Deposit
    </button>
  );
}

Chain Switching

tsx
import { useSwitchChain, useChainId } from 'wagmi';
import { base, optimism } from 'wagmi/chains';

function ChainSwitcher() {
  const chainId = useChainId();
  const { switchChain } = useSwitchChain();

  return (
    <div>
      <p>Current chain: {chainId}</p>
      <button onClick={() => switchChain({ chainId: base.id })}>Switch to Base</button>
      <button onClick={() => switchChain({ chainId: optimism.id })}>Switch to Optimism</button>
    </div>
  );
}

ENS Resolution

tsx
import { useEnsName, useEnsAddress, useEnsAvatar } from 'wagmi';

function ENSProfile({ address }: { address: `0x${string}` }) {
  const { data: name } = useEnsName({ address });
  const { data: avatar } = useEnsAvatar({ name: name ?? undefined });

  return (
    <div>
      {avatar && <img src={avatar} alt="ENS avatar" />}
      <span>{name ?? `${address.slice(0, 6)}...${address.slice(-4)}`}</span>
    </div>
  );
}

viem Direct Usage (Non-React)

typescript
import { createPublicClient, createWalletClient, http, parseAbi } from 'viem';
import { base } from 'viem/chains';

const publicClient = createPublicClient({ chain: base, transport: http() });

const balance = await publicClient.readContract({
  address: '0xToken',
  abi: parseAbi(['function balanceOf(address) view returns (uint256)']),
  functionName: 'balanceOf',
  args: ['0xAddress'],
});

const logs = await publicClient.getLogs({
  address: '0xContract',
  event: parseAbi(['event Transfer(address indexed, address indexed, uint256)'])[0],
  fromBlock: 'earliest',
  toBlock: 'latest',
});

Best Practices

  • Always simulate before writing (useSimulateContract → useWriteContract)
  • Use useWaitForTransactionReceipt for confirmation — don't assume tx is mined
  • Batch reads with useReadContracts to reduce RPC calls
  • Handle all states: loading, error, success, pending confirmation
  • Use parseAbi for inline ABI definitions (type-safe)
  • Set query.enabled to conditionally run hooks
  • Display tx hash link to block explorer while waiting for confirmation

© ccashwell, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/dapp-frontend-patterns of ccashwell/evm-cortex.

Open the folder on GitHubat commit f8f3301

Compare with similar skills

Dapp Frontend Patterns next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Dapp Frontend Patterns compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Dapp Frontend Patterns this skillccashwell/evm-cortex131—~1.9kAutomated safety check: PassMIT
Grazgraz-sh/graz123—~4.2kAutomated safety check: PassMIT
Bridge Stablecoincirclefin/skills155—~3.4kAutomated safety check: NotesApache-2.0
NEAR dApp Builderinternet-court/internet-court-skill6.4k1 repos~684Automated safety check: PassCustom licence
Frontend Playbookaustintgriffith/ethskills294—~3.4kAutomated safety check: NotesNone
Frontend UXaustintgriffith/ethskills294—~1.5kAutomated safety check: PassNone

Similar skills

  • Graz

    graz-sh/graz

    React hooks for Cosmos blockchain interactions — connect wallets, query balances, send tokens, sign messages.

    123 GitHub stars~4.2k tokensUpdated 19 days ago
    Frontend & DesignAuto-check passed
  • Bridge Stablecoin

    circlefin/skills

    Build browser or server USDC bridging with Circle App Kit or standalone Bridge Kit and CCTP.

    155 GitHub stars~3.4k tokensUpdated 21 days ago
    Business, Finance & HRAuto-check: notes
  • NEAR dApp Builder

    internet-court/internet-court-skill

    Scaffolds new NEAR dApps with create-near-app or adds NEAR wallet sign-in, contract calls and transaction signing to an existing React or plain JavaScript app.

    6.4k GitHub starsUsed in 1 repo~684 tokens
    Frontend & DesignAuto-check passed
  • Frontend Playbook

    austintgriffith/ethskills

    The complete build-to-production pipeline for Ethereum dApps.

    294 GitHub stars~3.4k tokensUpdated 1 mo ago
    Frontend & DesignAuto-check: notes
  • Frontend UX

    austintgriffith/ethskills

    Frontend UX rules for Ethereum dApps that prevent the most common AI agent UI bugs.

    294 GitHub stars~1.5k tokensUpdated 1 mo ago
    Frontend & DesignAuto-check passed
  • Vechain Kit

    vechain/x-app-template

    VeChain Kit and dapp-kit packages — installation, hooks, components, wallet connection, social login, smart accounts, theming, and Privy setup.

    450 GitHub stars~1.4k tokensUpdated 2 mo ago
    Frontend & DesignAuto-check passed

More from ccashwell/evm-cortex

All 89 skills in this repo
  • Xray Pre Audit

    ccashwell/evm-cortex

    A skill your agent uses when preparing for a security audit, performing reconnaissance on a new codebase, or creating a protocol overview.

    131 GitHub stars~25k tokensUpdated 7 days ago
    Auto-check passed
  • Aave Integration

    ccashwell/evm-cortex

    A skill your agent uses when integrating with Aave V3 for lending, borrowing, flash loans, or building on top of Aave markets.

    131 GitHub stars~1.3k tokensUpdated 7 days ago
    Auto-check passed
  • Access Control Patterns

    ccashwell/evm-cortex

    Access control design patterns for Solidity protocols. An agent skill from ccashwell/evm-cortex.

    131 GitHub stars~1.8k tokensUpdated 7 days ago
    Auto-check passed
  • Anvil Patterns

    ccashwell/evm-cortex

    A skill your agent uses when running a local Ethereum node with Anvil.

    131 GitHub stars~1.3k tokensUpdated 7 days ago
    Auto-check passed
  • Audit Breadth Scan

    ccashwell/evm-cortex

    A skill your agent uses when performing systematic breadth-first review of all contracts during a security audit.

    131 GitHub stars~1.4k tokensUpdated 7 days ago
    Auto-check passed
  • Audit Depth Analysis

    ccashwell/evm-cortex

    A skill your agent uses when performing deep analysis of specific findings or high-risk areas during a security audit.

    131 GitHub stars~1.6k tokensUpdated 7 days ago
    Auto-check passed

Works with

Questions about Dapp Frontend Patterns

What does Dapp Frontend Patterns do?

A skill your agent uses when building dApp frontends with wagmi v2 and viem. Dapp Frontend Patterns is an agent skill from ccashwell/evm-cortex. Use when building dApp frontends with wagmi v2 and viem.

When should I use Dapp Frontend Patterns?

Dapp Frontend Patterns fits situations like: building dApp frontends with wagmi v2 and viem; tasks that involve Smart contracts.

How do I install Dapp Frontend Patterns in Claude Code?

Run `npx skills add ccashwell/evm-cortex --skill dapp-frontend-patterns -a claude-code`. Or copy the skill folder (skills/dapp-frontend-patterns in ccashwell/evm-cortex) into .claude/skills/dapp-frontend-patterns in your project. Claude Code loads it when a task matches its description.

How do I install Dapp Frontend Patterns in Codex?

Run `npx skills add ccashwell/evm-cortex --skill dapp-frontend-patterns -a codex`. Or copy the skill folder (skills/dapp-frontend-patterns in ccashwell/evm-cortex) into .agents/skills/dapp-frontend-patterns in your project. Codex loads it when a task matches its description.

Can I use Dapp Frontend Patterns in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add ccashwell/evm-cortex --skill dapp-frontend-patterns -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/dapp-frontend-patterns, .gemini/skills/dapp-frontend-patterns, .github/skills/dapp-frontend-patterns and .opencode/skills/dapp-frontend-patterns in your project.

What does Dapp Frontend Patterns need to run?

Going by SKILL.md and its folder, Dapp Frontend Patterns needs the command-line tools its instructions call (npm). Our summary lists: Node.js.

Does Dapp Frontend Patterns access the network?

SKILL.md contains no URLs. Its commands use npm, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Dapp Frontend Patterns safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Dapp Frontend Patterns use?

Dapp Frontend Patterns is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Dapp Frontend Patterns use?

About 1.9k tokens (SKILL.md is roughly 7.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Dapp Frontend Patterns?

Skills that share tags, products or a category with Dapp Frontend Patterns: Graz (graz-sh/graz, 123 stars), Bridge Stablecoin (circlefin/skills, 155 stars), NEAR dApp Builder (internet-court/internet-court-skill, 6.4k stars) and Frontend Playbook (austintgriffith/ethskills, 294 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Dapp Frontend Patterns?

ccashwell (a GitHub user) maintains it in ccashwell/evm-cortex, which has 131 GitHub stars. The repository holds 89 skills in this directory. The repository was last updated on September 30, 2026.

Source: ccashwell/evm-cortex on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.