viem
Use viem for Celo development. Includes fee currency support, transaction signing, and Celo-specific configurations.
Best use case
viem is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Use viem for Celo development. Includes fee currency support, transaction signing, and Celo-specific configurations.
Teams using viem should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/viem/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How viem Compares
| Feature / Agent | viem | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Use viem for Celo development. Includes fee currency support, transaction signing, and Celo-specific configurations.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Viem for Celo
Viem is a lightweight TypeScript library with first-class Celo support. It powers wagmi and RainbowKit.
Source: https://viem.sh/docs/chains/celo
## When to Use
- Building dApps that interact with Celo
- Sending transactions with alternative fee currencies
- Reading contract state and blockchain data
- Signing messages and transactions
## Installation
```bash
npm install viem
```
## Chain Configuration
Source: https://github.com/wevm/viem (chain definitions)
### Mainnet
```typescript
import { celo } from "viem/chains";
// Chain ID: 42220
// RPC: https://forno.celo.org
// Explorer: https://celoscan.io
```
### Testnet (Celo Sepolia)
```typescript
import { celoSepolia } from "viem/chains";
// Chain ID: 11142220
// RPC: https://forno.celo-sepolia.celo-testnet.org
// Explorer: https://celo-sepolia.blockscout.com
```
### Custom Chain with Celo Config
```typescript
import { defineChain } from "viem";
import { chainConfig } from "viem/celo";
export const customCeloChain = defineChain({
...chainConfig,
id: 42220,
name: "Custom Celo",
// ...
});
```
## Client Setup
### Public Client (Read Operations)
```typescript
import { createPublicClient, http } from "viem";
import { celo } from "viem/chains";
const publicClient = createPublicClient({
chain: celo,
transport: http(),
});
// Read contract state
const balance = await publicClient.getBalance({
address: "0x...",
});
```
### Wallet Client (Write Operations)
```typescript
import { createWalletClient, custom } from "viem";
import { celo } from "viem/chains";
const walletClient = createWalletClient({
chain: celo,
transport: custom(window.ethereum),
});
const [address] = await walletClient.getAddresses();
```
## Fee Currency Support
Celo allows paying gas fees in tokens other than CELO. Use whitelisted fee currency adapters.
Source: https://viem.sh/docs/chains/celo
### Fee Currency Addresses - Mainnet
| Token | Adapter Address |
|-------|-----------------|
| USDC | 0x2F25deB3848C207fc8E0c34035B3Ba7fC157602B |
| USDT | 0x0e2a3e05bc9a16f5292a6170456a710cb89c6f72 |
### Fee Currency Addresses - Celo Sepolia
| Token | Adapter Address |
|-------|-----------------|
| USDC | 0x4822e58de6f5e485eF90df51C41CE01721331dC0 |
### Serialize Transaction with Fee Currency
```typescript
import { serializeTransaction } from "viem/celo";
import { parseGwei, parseEther } from "viem";
const serialized = serializeTransaction({
chainId: 42220,
gas: 21001n,
feeCurrency: "0x2F25deB3848C207fc8E0c34035B3Ba7fC157602B", // USDC adapter
maxFeePerGas: parseGwei("20"),
maxPriorityFeePerGas: parseGwei("2"),
nonce: 69,
to: "0x1234512345123451234512345123451234512345",
value: parseEther("0.01"),
});
```
### Send Transaction with Fee Currency
```typescript
import { createWalletClient, custom, parseEther } from "viem";
import { celo } from "viem/chains";
const USDC_ADAPTER = "0x2F25deB3848C207fc8E0c34035B3Ba7fC157602B";
const walletClient = createWalletClient({
chain: celo,
transport: custom(window.ethereum),
});
const [address] = await walletClient.getAddresses();
// Send transaction paying gas in USDC
const hash = await walletClient.sendTransaction({
account: address,
to: "0x...",
value: parseEther("1"),
feeCurrency: USDC_ADAPTER,
});
```
### Contract Call with Fee Currency
```typescript
const hash = await walletClient.writeContract({
address: CONTRACT_ADDRESS,
abi: CONTRACT_ABI,
functionName: "transfer",
args: [recipient, amount],
feeCurrency: USDC_ADAPTER,
});
```
## Celo Utilities
### Parse Transaction
```typescript
import { parseTransaction } from "viem/celo";
// Supports CIP-64, EIP-1559, EIP-2930, and Legacy transactions
const transaction = parseTransaction("0x7cf846...");
```
### Serialize Transaction
```typescript
import { serializeTransaction } from "viem/celo";
const serialized = serializeTransaction({
chainId: 42220,
feeCurrency: "0x2F25deB3848C207fc8E0c34035B3Ba7fC157602B",
// ... other params
});
```
## Reading Contract Data
```typescript
import { createPublicClient, http } from "viem";
import { celo } from "viem/chains";
const publicClient = createPublicClient({
chain: celo,
transport: http(),
});
const ERC20_ABI = [
{
name: "balanceOf",
type: "function",
stateMutability: "view",
inputs: [{ name: "account", type: "address" }],
outputs: [{ type: "uint256" }],
},
] as const;
const balance = await publicClient.readContract({
address: "0x765de816845861e75a25fca122bb6898b8b1282a", // USDm
abi: ERC20_ABI,
functionName: "balanceOf",
args: ["0x..."],
});
```
## Multicall
Batch multiple read calls efficiently:
```typescript
const results = await publicClient.multicall({
contracts: [
{
address: TOKEN_ADDRESS,
abi: ERC20_ABI,
functionName: "balanceOf",
args: [userAddress],
},
{
address: TOKEN_ADDRESS,
abi: ERC20_ABI,
functionName: "totalSupply",
},
],
});
```
## Important Notes
- Viem is the recommended library for Celo (ethers.js and web3.js don't support `feeCurrency`)
- Fee currency transactions use type `0x7b` (CIP-64)
- Transactions with fee currencies incur ~50,000 additional gas
- Omitting `feeCurrency` defaults to paying in CELO
- Use `viem/celo` for Celo-specific utilities (parseTransaction, serializeTransaction)
## Dependencies
```json
{
"dependencies": {
"viem": "^2.0.0"
}
}
```
## Additional Resources
- [fee-currencies.md](references/fee-currencies.md) - Complete fee currency referenceRelated Skills
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.
8004-skill
ERC-8004 Trustless Agents - Register and manage AI agent identities on TRON and BSC blockchains with on-chain reputation tracking
8004-MCP - Agent Registry Protocol
Multi-chain MCP server for ERC-8004 Agent Registry. Query agents, reputation, and feedback across Solana + EVM chains.
supurr
Backtest, deploy, and monitor trading bots on Hyperliquid. Supports Grid, DCA, and Spot-Perp Arbitrage strategies across Native Perps, Spot markets (USDC/USDH), and HIP-3 sub-DEXes.
senpi-skills
Agent Skills for autonomous crypto trading on Hyperliquid — trailing stops, market scanning, position management, and more.
sdks
Official Azex SDKs — TypeScript, Python, MCP Server, CLI for the crypto-native LLM API gateway
perp-cli
Multi-DEX perpetual futures CLI + MCP server — Pacifica (Solana), Hyperliquid, Lighter (Ethereum). 18 MCP tools for AI-powered trading
okx-exchange-websocket-skill
Subscribe to OKX public exchange WebSocket channels through UXC raw WebSocket mode for ticker, trade, book, and candle events with explicit subscribe frames.
okx-wallet-portfolio
This skill should be used when the user asks to 'check my wallet balance', 'show my token holdings', 'how much OKB do I have', 'what tokens do I have', 'check my portfolio value', 'view my assets', 'how much is my portfolio worth', 'what\'s in my wallet', or mentions checking wallet balance, total assets, token holdings, portfolio value, remaining funds, DeFi positions, or multi-chain balance lookup. Supports XLayer, Solana, Ethereum, Base, BSC, Arbitrum, Polygon, and 20+ other chains. Do NOT use for general programming questions about balance variables or API documentation. Do NOT use when the user is asking how to build or integrate a balance feature into code.
okx-security
Use this skill for security scanning: check transaction safety, is this transaction safe, pre-execution check, security scan, token risk scanning, honeypot detection, DApp/URL phishing detection, message signature safety, malicious transaction detection, approval safety checks, token approval management. Triggers: 'is this token safe', 'check token security', 'honeypot check', 'scan this tx', 'scan this swap tx', 'tx risk check', 'is this URL a scam', 'check if this dapp is safe', 'phishing site check', 'is this signature safe', 'check this signing request', 'check my approvals', 'show risky approvals', 'revoke approval', 'check if this approve is safe', token authorization, ERC20 allowance, Permit2. Covers token-scan, dapp-scan, tx-scan (EVM+Solana pre-execution), sig-scan (EIP-712/personal_sign), approvals (ERC-20/Permit2). Chinese: 安全扫描, 代币安全, 蜜罐检测, 貔貅盘, 钓鱼网站, 交易安全, 签名安全, 代币风险, 授权管理, 授权查询, 风险授权, 代币授权. Do NOT use for wallet balance/send/history — use okx-agentic-wallet.
okx-onchain-gateway
This skill should be used when the user asks to 'broadcast transaction', 'send tx', 'estimate gas', 'simulate transaction', 'check tx status', 'track my transaction', 'get gas price', 'gas limit', 'broadcast signed tx', or mentions broadcasting transactions, sending transactions on-chain, gas estimation, transaction simulation, tracking broadcast orders, or checking transaction status. Covers gas price, gas limit estimation, transaction simulation, transaction broadcasting, and order tracking across XLayer, Solana, Ethereum, Base, BSC, Arbitrum, Polygon, and 20+ other chains. Do NOT use for swap quote or execution - use okx-dex-swap instead. Do NOT use for general programming questions about transaction handling.
okx-x402-payment
This skill should be used when the user encounters an HTTP 402 Payment Required response, wants to pay for a payment-gated API or resource, or mentions 'x402', 'pay for access', '402 payment', 'payment-gated URL', or 'sign x402 payment'. Primary path signs via TEE with a wallet session (JWT); fallback path guides local EIP-3009 signing with the user's own private key if they have no wallet. Returns the payment proof (signature + authorization) that the caller can attach as a payment header to access the resource. Do NOT use for swap or token transfers — use okx-dex-swap instead. Do NOT use for wallet balance or portfolio queries — use okx-agentic-wallet or okx-wallet-portfolio. Do NOT use for security scanning — use okx-security. Do NOT use for transaction broadcasting — use okx-onchain-gateway. Do NOT use for general programming questions.