Viem blockchain client patterns for Ethereum interactions, transactions, signing, encoding, and smart contract calls. Triggers on viem, publicClient, walletClient, chain, abi.
Provides viem blockchain client patterns for Ethereum interactions, transactions, signing, encoding, and smart contract calls. Triggers on viem, publicClient, walletClient, chain, abi.
/plugin marketplace add settlemint/agent-marketplace/plugin install devtools@settlemintThis skill inherits all available tools. When active, it can use any tool Claude has access to.
<mcp_first> CRITICAL: Always fetch viem documentation before implementing.
MCPSearch({ query: "select:mcp__plugin_devtools_context7__query-docs" })
// Client patterns
mcp__context7__query_docs({
libraryId: "/wevm/viem",
query: "How do I use createPublicClient and createWalletClient?",
});
// Contract interactions
mcp__context7__query_docs({
libraryId: "/wevm/viem",
query: "How do I use readContract, writeContract, and simulateContract?",
});
// Signing
mcp__context7__query_docs({
libraryId: "/wevm/viem",
query: "How do I use signMessage and signTypedData with EIP-712?",
});
// Encoding
mcp__context7__query_docs({
libraryId: "/wevm/viem",
query:
"How do I use encodeFunctionData, decodeFunctionResult, and encodeAbiParameters?",
});
Note: Context7 v2 uses server-side filtering. Use descriptive natural language queries. </mcp_first>
<quick_start> Create clients:
import { createPublicClient, createWalletClient, http } from "viem";
import { mainnet } from "viem/chains";
import { privateKeyToAccount } from "viem/accounts";
const publicClient = createPublicClient({
chain: mainnet,
transport: http(),
});
const walletClient = createWalletClient({
chain: mainnet,
transport: http(),
account: privateKeyToAccount("0x..."),
});
Read contract:
const balance = await publicClient.readContract({
address: "0x...",
abi: erc20Abi,
functionName: "balanceOf",
args: [userAddress],
});
Write contract:
const hash = await walletClient.writeContract({
address: "0x...",
abi: erc20Abi,
functionName: "transfer",
args: [recipient, amount],
});
const receipt = await publicClient.waitForTransactionReceipt({ hash });
</quick_start>
<client_types>
| Client | Purpose | Example Use |
|---|---|---|
PublicClient | Reading blockchain data | getBlockNumber(), readContract() |
WalletClient | Transaction signing/sending | sendTransaction(), signMessage() |
TestClient | Testing and simulation | mine(), setBalance() |
BundlerClient | ERC-4337 User Operations | sendUserOperation() |
| </client_types> |
import { parseEther, formatEther, parseUnits, formatUnits } from "viem";
parseEther("1.5"); // 1500000000000000000n
formatEther(1500000000000000000n); // "1.5"
parseUnits("100", 6); // 100000000n (USDC)
formatUnits(100000000n, 6); // "100"
Address utilities:
import { getAddress, isAddress } from "viem";
getAddress("0xabc..."); // Checksummed address
isAddress("0x..."); // Validates format
</utilities>
<constraints>
**Banned:** SSRF protection for config-sourced URLs (they're developer-controlled)
Required:
<success_criteria>
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.