AgentSkillsCN

evm-blockchain

支持 EVM 区块链操作,包括余额查询、交易、代币转账、智能合约交互以及 ENS 查询。无论您是在以太坊、Polygon、Arbitrum、Optimism、Base、BSC、Avalanche,还是其他兼容 EVM 的链上开展开发,此技能都能助您一臂之力。

SKILL.md
--- frontmatter
name: evm-blockchain
description: EVM blockchain operations including balance queries, transactions, token transfers, smart contract interactions, and ENS lookups. Use when working with Ethereum, Polygon, Arbitrum, Optimism, Base, BSC, Avalanche, or other EVM-compatible chains.
allowed-tools: Read, Bash, WebFetch

EVM Blockchain Operations

A comprehensive skill for interacting with EVM-compatible blockchains using the viem library.

Supported Networks

Mainnets

  • Ethereum (mainnet, eth)
  • Optimism (optimism, op)
  • Arbitrum (arbitrum, arb)
  • Arbitrum Nova
  • Base
  • Polygon (polygon, matic)
  • Polygon zkEVM
  • Avalanche (avalanche, avax)
  • BSC (binance, bsc)
  • zkSync
  • Linea
  • Celo
  • Gnosis (gnosis, xdai)
  • Fantom (fantom, ftm)
  • Filecoin
  • Moonbeam
  • Moonriver
  • Cronos
  • Scroll
  • Mantle
  • Manta
  • Blast
  • Fraxtal
  • Mode
  • Metis
  • Kroma
  • Zora
  • Aurora
  • Canto
  • Flow

Testnets

  • Sepolia
  • Optimism Sepolia
  • Arbitrum Sepolia
  • Base Sepolia
  • Polygon Amoy
  • Avalanche Fuji
  • BSC Testnet
  • And many more...

Quick Reference

For detailed operations, see:

Installation

bash
bun add viem

Basic Usage

typescript
import { createPublicClient, http } from 'viem';
import { mainnet } from 'viem/chains';

const client = createPublicClient({
  chain: mainnet,
  transport: http('https://eth.llamarpc.com')
});

// Get balance
const balance = await client.getBalance({
  address: '0x...'
});

// Get block
const block = await client.getBlock();

Common Operations

Get ETH Balance

typescript
import { formatEther } from 'viem';

const balance = await client.getBalance({
  address: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045' // vitalik.eth
});
console.log(formatEther(balance)); // "1234.56789"

Get ERC20 Token Balance

typescript
const balance = await client.readContract({
  address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
  abi: [{
    name: 'balanceOf',
    type: 'function',
    stateMutability: 'view',
    inputs: [{ name: 'account', type: 'address' }],
    outputs: [{ type: 'uint256' }]
  }],
  functionName: 'balanceOf',
  args: ['0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045']
});

Resolve ENS Name

typescript
const address = await client.getEnsAddress({
  name: 'vitalik.eth'
});
// Returns: 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045

Get Transaction Details

typescript
const tx = await client.getTransaction({
  hash: '0x...'
});

Estimate Gas

typescript
const gas = await client.estimateGas({
  to: '0x...',
  value: parseEther('0.1')
});

Security Notes

  • Never expose private keys in code or logs
  • Always validate addresses before transactions
  • Use testnets for development and testing
  • Double-check recipient addresses for transfers