Skip to main content
viem-integration Integrate EVM blockchains using viem. Use when user says "read blockchain data", "send transaction", "interact with smart contract", "connect to Ethereum", "use viem", "use wagmi", "wallet integration", "viem setup", or mentions blockchain/EVM development with TypeScript.
Zur Installation springen Skills Marktplatz Entdecken und erkunden Sie KI-Skills, die von der Community erstellt wurden.
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Prompt kopierenPrompt-Details anzeigen Ein direkter Befehl überspringt den Prüf-Prompt. Prüfen Sie die Quelle, bevor Sie ihn ausführen.
npx skills add https://github.com/Uniswap/uniswap-ai --skill viem-integrationDer Befehl bleibt in einer Zeile. Scrollen Sie horizontal, um ihn vor dem Kopieren vollständig zu prüfen.
Sie bevorzugen eine lokale Kopie? Laden Sie die Dateien herunter, die SkillsMP derzeit vorliegen.
ZIP herunterladen Herunterladen... Mehr aus diesem Repository This skill should be used when the user asks to "provide liquidity", "create LP position", "add liquidity to pool", "become a liquidity provider", "create v3 position", "create v4 position", "concentrated liquidity", "set price range", or mentions providing liquidity, LP positions, or liquidity pools on Uniswap. Generates deep links to create positions in the Uniswap interface.
This skill should be used when the user asks to "swap tokens", "trade ETH for USDC", "exchange tokens on Uniswap", "buy tokens", "sell tokens", "convert ETH to stablecoins", "find memecoins", "discover tokens", "research tokens", "tokens to buy", "find tokens to swap", "what should I buy", or mentions swapping, trading, researching, discovering, buying, or exchanging tokens on any Uniswap-supported chain. Supports both known token swaps and token discovery workflows (discovery uses keyword search and web search — there is no live "trending" feed). Generates deep links to execute swaps in the Uniswap interface.
Integrate Uniswap liquidity provisioning (LP) into applications via the LP REST API. Use when the user says "LP API", "liquidity provisioning API", "provide liquidity programmatically", "create LP position via API", "add liquidity via API", "increase liquidity", "decrease liquidity", "remove liquidity", "claim LP fees", "collect LP fees", "manage LP positions in code", or mentions building a backend, bot, or frontend that creates or manages Uniswap v2/v3/v4 liquidity positions through an API. Also use when debugging LP API calls (e.g. /lp/create, /lp/check_approval, /lp/increase, /lp/decrease, /lp/claim_fees), unexpected response fields, the approval or EIP-712 permit flow, or transaction-building errors for liquidity positions. For generating deep links to the Uniswap web app instead of calling the API, use the liquidity-planner skill; for using the Uniswap v4 SDK directly rather than the REST API, use the v4-sdk-integration skill.
Verwandte Berufe SOC
Basierend auf der SOC-Berufsklassifikation
name viem-integration description Integrate EVM blockchains using viem. Use when user says "read blockchain data", "send transaction", "interact with smart contract", "connect to Ethereum", "use viem", "use wagmi", "wallet integration", "viem setup", or mentions blockchain/EVM development with TypeScript. allowed-tools Read, Write, Edit, Glob, Grep, Bash(npm:*), Bash(npx:*), WebFetch, Task(subagent_type:viem-integration-expert) model opus license MIT metadata {"author":"uniswap","version":"1.0.0"}
viem Integration
Integrate EVM blockchains using viem for TypeScript/JavaScript applications.
Quick Decision Guide
Building... Use This Node.js script/backend viem with http transport React/Next.js frontend wagmi hooks (built on viem) Real-time event monitoring
viem with webSocket transport
Browser wallet integration wagmi or viem custom transport
Installation
npm install viem
npm install wagmi viem @tanstack/react-query
Core Concepts
Clients viem uses two client types:
Client Purpose Example Use PublicClient Read-only operations Get balances, read contracts, fetch logs WalletClient Write operations Send transactions, sign messages
Transports Transport Use Case http()Standard RPC calls (most common) webSocket()Real-time event subscriptions custom()Browser wallets (window.ethereum)
Chains viem includes 50+ chain definitions. Import from viem/chains:
import { mainnet, arbitrum, optimism, base, polygon } from 'viem/chains' ;
Input Validation Rules Before interpolating ANY user-provided value into generated TypeScript code:
Ethereum addresses : MUST match ^0x[a-fA-F0-9]{40}$ — use viem's isAddress() for validation
Chain IDs : MUST be from viem's supported chain definitions
Private keys : MUST NEVER be hardcoded — always use process.env.PRIVATE_KEY with runtime validation
RPC URLs : MUST use https:// or wss:// protocols only
ABI inputs : Validate types match expected Solidity types before encoding
Quick Start Examples
Read Balance import { createPublicClient, http, formatEther } from 'viem' ;
import { mainnet } from 'viem/chains' ;
const client = createPublicClient ({
chain : mainnet,
transport : http (),
});
const balance = await client.getBalance ({
address : '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' ,
});
console .log (`Balance: ${formatEther(balance)} ETH` );
Read Contract import { createPublicClient, http, parseAbi } from 'viem' ;
import { mainnet } from 'viem/chains' ;
const client = createPublicClient ({
chain : mainnet,
transport : http (),
});
const abi = parseAbi ([
'function balanceOf(address) view returns (uint256)' ,
'function decimals() view returns (uint8)' ,
]);
const balance = await client.readContract ({
address : '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' ,
abi,
functionName : 'balanceOf' ,
args : ['0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' ],
});
Send Transaction import { createWalletClient, http, parseEther } from 'viem' ;
import { privateKeyToAccount } from 'viem/accounts' ;
import { mainnet } from 'viem/chains' ;
const account = privateKeyToAccount (process.env .PRIVATE_KEY as `0x${string } ` );
const client = createWalletClient ({
account,
chain : mainnet,
transport : http (),
});
const hash = await client.sendTransaction ({
to : '0x...' ,
value : parseEther ('0.1' ),
});
console .log (`Transaction hash: ${hash} ` );
Write to Contract import { createWalletClient, createPublicClient, http, parseAbi, parseUnits } from 'viem' ;
import { privateKeyToAccount } from 'viem/accounts' ;
import { mainnet } from 'viem/chains' ;
const account = privateKeyToAccount (process.env .PRIVATE_KEY as `0x${string } ` );
const walletClient = createWalletClient ({
account,
chain : mainnet,
transport : http (),
});
const publicClient = createPublicClient ({
chain : mainnet,
transport : http (),
});
const abi = parseAbi (['function transfer(address to, uint256 amount) returns (bool)' ]);
const { request } = await publicClient.simulateContract ({
address : '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' ,
abi,
functionName : 'transfer' ,
args : ['0x...' , parseUnits ('100' , 6 )],
account,
});
const hash = await walletClient.writeContract (request);
const receipt = await publicClient.waitForTransactionReceipt ({ hash });
console .log (`Confirmed in block ${receipt.blockNumber} ` );
Reference Documentation For deeper coverage of specific topics:
Related Plugins Once you're comfortable with viem basics, the uniswap-trading plugin provides comprehensive Uniswap swap integration:
Uniswap Trading API integration
Universal Router SDK usage
Token swap implementations
Install it with: claude plugin add @uniswap/uniswap-trading
Common Utilities
Unit Conversion import { parseEther, formatEther, parseUnits, formatUnits } from 'viem' ;
parseEther ('1.5' );
formatEther (1500000000000000000n );
parseUnits ('100' , 6 );
formatUnits (100000000n , 6 );
Address Utilities import { getAddress, isAddress } from 'viem' ;
isAddress ('0x...' );
getAddress ('0x...' );
Hashing import { keccak256, toHex } from 'viem' ;
keccak256 (toHex ('hello' ));
Error Handling viem throws typed errors that can be caught and handled:
import { ContractFunctionExecutionError , InsufficientFundsError } from 'viem'
try {
await client.writeContract (...)
} catch (error) {
if (error instanceof ContractFunctionExecutionError ) {
console .error ('Contract call failed:' , error.shortMessage )
}
if (error instanceof InsufficientFundsError ) {
console .error ('Not enough ETH for gas' )
}
}
Resources