cli-cast by paulrberg/agent-skills
npx skills add https://github.com/paulrberg/agent-skills --skill cli-castFoundry cast CLI 的专家指南——这是一款用于从命令行与 EVM 兼容区块链交互的瑞士军刀。使用此技能来签署交易、将其发送到链上 RPC、读取链上状态、编码/解码 ABI 数据以及管理钱包。
核心能力:
所有链上命令都需要一个 RPC 端点。当解析出的链是 RouteMesh 支持的链时,使用 RouteMesh 作为默认的 RPC 提供商。如果 $evm-chains 标记该链不受 RouteMesh 支持,则使用该链的默认公共 RPC。
URL 模式:
https://lb.routeme.sh/rpc/{CHAIN_ID}/{ROUTEMESH_API_KEY}
构建 RPC URL 的方法是:首先使用 $evm-chains 解析链,如果 RouteMesh 支持该链,则读取 ROUTEMESH_API_KEY 环境变量。如果 $evm-chains 不可用,请告知用户他们可以通过 安装此技能集合;在此之前,仅将 作为常见网络的有限备用方案。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
npx skills add PaulRBerg/agent-skillsreferences/chains.md在运行任何链上命令之前,请验证 ROUTEMESH_API_KEY 是否已设置:
if [[ -z "$ROUTEMESH_API_KEY" ]]; then
echo "Error: ROUTEMESH_API_KEY is not set"
exit 1
fi
使用链 ID 的示例:
# 以太坊主网 (链 ID 1)
cast call "$CONTRACT" "balanceOf(address)" "$ADDR" \
--rpc-url "https://lb.routeme.sh/rpc/1/$ROUTEMESH_API_KEY"
# Arbitrum (链 ID 42161)
cast send "$CONTRACT" "transfer(address,uint256)" "$TO" "$AMOUNT" \
--rpc-url "https://lb.routeme.sh/rpc/42161/$ROUTEMESH_API_KEY" \
--private-key "$ETH_PRIVATE_KEY"
Cast 支持多种签名方法。请根据安全上下文进行选择。
默认私钥: 从环境中读取 ETH_PRIVATE_KEY。如果该变量未设置且任务需要签名(例如 cast send、cast mktx、cast wallet sign),请停止并告知用户未找到私钥,然后要求他们执行以下操作之一:
ETH_PRIVATE_KEY,或者cast send "$CONTRACT" "approve(address,uint256)" "$SPENDER" "$AMOUNT" \
--rpc-url "$RPC_URL" \
--private-key "$ETH_PRIVATE_KEY"
# 将私钥导入密钥库
cast wallet import my-account --interactive
# 使用密钥库账户
cast send "$CONTRACT" "transfer(address,uint256)" "$TO" "$AMOUNT" \
--rpc-url "$RPC_URL" \
--account my-account
# Ledger
cast send "$CONTRACT" "transfer(address,uint256)" "$TO" "$AMOUNT" \
--rpc-url "$RPC_URL" \
--ledger
使用 cast send 在链上提交改变状态的交易。
# 发送 ETH
cast send "$TO" --value 1ether \
--rpc-url "$RPC_URL" \
--private-key "$ETH_PRIVATE_KEY"
# 调用合约函数
cast send "$CONTRACT" "approve(address,uint256)" "$SPENDER" "$AMOUNT" \
--rpc-url "$RPC_URL" \
--private-key "$ETH_PRIVATE_KEY"
# 附带 gas 参数
cast send "$CONTRACT" "mint(uint256)" 100 \
--rpc-url "$RPC_URL" \
--private-key "$ETH_PRIVATE_KEY" \
--gas-limit 200000 \
--gas-price 20gwei
使用 cast call 进行不提交交易的只读调用。
# 读取单个值
cast call "$CONTRACT" "totalSupply()(uint256)" --rpc-url "$RPC_URL"
# 附带参数读取
cast call "$CONTRACT" "balanceOf(address)(uint256)" "$ADDR" --rpc-url "$RPC_URL"
# 读取多个返回值
cast call "$CONTRACT" "getReserves()(uint112,uint112,uint32)" --rpc-url "$RPC_URL"
当需要跨合约读取多个值时,使用 Multicall3 将它们批量处理为单个 RPC 调用。该合约已在 250 多个链上确定性地部署。
地址: 0xcA11bde05977b3631167028862bE2a173976CA11
使用 aggregate3 批量处理多个 cast call 读取:
MULTICALL3="0xcA11bde05977b3631167028862bE2a173976CA11"
# 编码每个子调用
CALL1=$(cast calldata "balanceOf(address)" "$ADDR")
CALL2=$(cast calldata "totalSupply()")
CALL3=$(cast calldata "decimals()")
# 通过 aggregate3 批量处理为单个 RPC 调用
# 每个元组是 (target, allowFailure, callData)
cast call "$MULTICALL3" \
"aggregate3((address,bool,bytes)[])(((bool,bytes)[]))" \
"[($TOKEN1,false,$CALL1),($TOKEN2,false,$CALL2),($TOKEN2,false,$CALL3)]" \
--rpc-url "$RPC_URL"
何时使用: 每当您需要在同一链上进行 2 次或更多次读取调用时,优先使用 Multicall3。它可以减少 RPC 往返次数,并保证所有结果都来自同一个区块。
注意事项: 下游调用中的 msg.sender 将变为 Multicall3 合约地址,而不是调用者。仅用于读取或 msg.sender 无关紧要的调用。
使用 cast mktx 创建已签名的原始交易而不广播它。
cast mktx "$CONTRACT" "transfer(address,uint256)" "$TO" "$AMOUNT" \
--rpc-url "$RPC_URL" \
--private-key "$ETH_PRIVATE_KEY"
# 查看交易详情
cast tx "$TX_HASH" --rpc-url "$RPC_URL"
# 查看交易收据
cast receipt "$TX_HASH" --rpc-url "$RPC_URL"
# 获取特定的收据字段
cast receipt "$TX_HASH" status --rpc-url "$RPC_URL"
cast receipt "$TX_HASH" gasUsed --rpc-url "$RPC_URL"
# 编码函数调用
cast calldata "transfer(address,uint256)" "$TO" "$AMOUNT"
# ABI 编码参数(不带函数选择器)
cast abi-encode "transfer(address,uint256)" "$TO" "$AMOUNT"
# 使用已知签名解码调用数据
cast decode-calldata "transfer(address,uint256)" "$CALLDATA"
# 解码 ABI 编码的数据(不带选择器)
cast abi-decode "balanceOf(address)(uint256)" "$DATA"
# 获取函数的 4 字节选择器
cast sig "transfer(address,uint256)"
# 获取事件主题哈希
cast sig-event "Transfer(address,address,uint256)"
# 生成新钱包
cast wallet new
# 从私钥获取地址
cast wallet address --private-key "$ETH_PRIVATE_KEY"
# 列出密钥库账户
cast wallet list
# 签署消息
cast wallet sign "Hello, world!" --private-key "$ETH_PRIVATE_KEY"
# 将 ENS 名称解析为地址
cast resolve-name "vitalik.eth" --rpc-url "$RPC_URL"
# 反向查找:地址到 ENS 名称
cast lookup-address "$ADDR" --rpc-url "$RPC_URL"
# 获取 ETH 余额
cast balance "$ADDR" --rpc-url "$RPC_URL"
# 以 ether 为单位获取余额(人类可读)
cast balance "$ADDR" --ether --rpc-url "$RPC_URL"
当用户按名称指定链时,请按照以下步骤解析链 ID:
$evm-chains —— 这是用于链名称、ID、默认公共 RPC、原生货币符号和 RouteMesh 支持的权威 Sablier-SDK 支持的数据集$evm-chains 不可用,请告知用户使用 npx skills add PaulRBerg/agent-skills 安装此集合,然后将 references/chains.md 作为常见网络的有限备用方案| 操作 | 命令 | 关键标志 |
|---|---|---|
| 发送交易 | cast send | --rpc-url, --private-key, --value |
| 读取状态 | cast call | --rpc-url, --block |
| 查看交易 | cast tx | --rpc-url, --json |
| 查看收据 | cast receipt | --rpc-url, --json |
| 构建交易 | cast mktx | --rpc-url, --private-key |
| 编码调用 | cast calldata | (函数签名 + 参数) |
| 解码调用 | cast decode-calldata | (函数签名 + 数据) |
| ABI 编码 | cast abi-encode | (函数签名 + 参数) |
| ABI 解码 | cast abi-decode | (函数签名 + 数据) |
| 函数签名 | cast sig | (函数签名字符串) |
| 批量读取 | cast call Multicall3 | aggregate3, --rpc-url |
| 余额 | cast balance | --rpc-url, --ether |
| ENS 解析 | cast resolve-name | --rpc-url |
| 新建钱包 | cast wallet new | — |
| 签署消息 | cast wallet sign | --private-key, --account |
$evm-chains —— Sablier SDK EVM 链数据和 RouteMesh 支持的首选来源每周安装次数
95
代码仓库
GitHub 星标数
41
首次出现
2026年2月12日
安全审计
安装于
claude-code89
codex84
opencode84
gemini-cli83
github-copilot83
amp83
Expert guidance for Foundry's cast CLI — the Swiss Army knife for interacting with EVM-compatible blockchains from the command line. Use this skill for signing transactions, sending them to chain RPCs, reading on-chain state, encoding/decoding ABI data, and managing wallets.
Key capabilities:
All on-chain commands require an RPC endpoint. Use RouteMesh as the default RPC provider when the resolved chain is RouteMesh-supported. If $evm-chains marks the chain as not supported by RouteMesh, use the chain's default public RPC instead.
URL pattern:
https://lb.routeme.sh/rpc/{CHAIN_ID}/{ROUTEMESH_API_KEY}
Construct the RPC URL by resolving the chain with $evm-chains first, then reading the ROUTEMESH_API_KEY environment variable if RouteMesh is supported. If $evm-chains is unavailable, tell the user they can install this skill collection with npx skills add PaulRBerg/agent-skills; until then, use references/chains.md only as a limited fallback for common networks.
Before running any on-chain command , verify that ROUTEMESH_API_KEY is set:
if [[ -z "$ROUTEMESH_API_KEY" ]]; then
echo "Error: ROUTEMESH_API_KEY is not set"
exit 1
fi
Example usage with a chain ID:
# Ethereum Mainnet (chain ID 1)
cast call "$CONTRACT" "balanceOf(address)" "$ADDR" \
--rpc-url "https://lb.routeme.sh/rpc/1/$ROUTEMESH_API_KEY"
# Arbitrum (chain ID 42161)
cast send "$CONTRACT" "transfer(address,uint256)" "$TO" "$AMOUNT" \
--rpc-url "https://lb.routeme.sh/rpc/42161/$ROUTEMESH_API_KEY" \
--private-key "$ETH_PRIVATE_KEY"
Cast supports multiple signing methods. Choose based on the security context.
Default private key: Read ETH_PRIVATE_KEY from the environment. If the variable is unset and the task requires signing (e.g., cast send, cast mktx, cast wallet sign), stop and inform the user that no private key was found, then ask them to either:
ETH_PRIVATE_KEY in their shell, orcast send "$CONTRACT" "approve(address,uint256)" "$SPENDER" "$AMOUNT" \
--rpc-url "$RPC_URL" \
--private-key "$ETH_PRIVATE_KEY"
# Import a private key into a keystore
cast wallet import my-account --interactive
# Use the keystore account
cast send "$CONTRACT" "transfer(address,uint256)" "$TO" "$AMOUNT" \
--rpc-url "$RPC_URL" \
--account my-account
# Ledger
cast send "$CONTRACT" "transfer(address,uint256)" "$TO" "$AMOUNT" \
--rpc-url "$RPC_URL" \
--ledger
Use cast send to submit state-changing transactions on-chain.
# Send ETH
cast send "$TO" --value 1ether \
--rpc-url "$RPC_URL" \
--private-key "$ETH_PRIVATE_KEY"
# Call a contract function
cast send "$CONTRACT" "approve(address,uint256)" "$SPENDER" "$AMOUNT" \
--rpc-url "$RPC_URL" \
--private-key "$ETH_PRIVATE_KEY"
# With gas parameters
cast send "$CONTRACT" "mint(uint256)" 100 \
--rpc-url "$RPC_URL" \
--private-key "$ETH_PRIVATE_KEY" \
--gas-limit 200000 \
--gas-price 20gwei
Use cast call for read-only calls that do not submit transactions.
# Read a single value
cast call "$CONTRACT" "totalSupply()(uint256)" --rpc-url "$RPC_URL"
# Read with arguments
cast call "$CONTRACT" "balanceOf(address)(uint256)" "$ADDR" --rpc-url "$RPC_URL"
# Read multiple return values
cast call "$CONTRACT" "getReserves()(uint112,uint112,uint32)" --rpc-url "$RPC_URL"
When reading multiple values across contracts, batch them into a single RPC call using Multicall3. This is deployed at a deterministic address on 250+ chains.
Address: 0xcA11bde05977b3631167028862bE2a173976CA11
Use aggregate3 to batch multiple cast call reads:
MULTICALL3="0xcA11bde05977b3631167028862bE2a173976CA11"
# Encode each sub-call
CALL1=$(cast calldata "balanceOf(address)" "$ADDR")
CALL2=$(cast calldata "totalSupply()")
CALL3=$(cast calldata "decimals()")
# Batch into a single RPC call via aggregate3
# Each tuple is (target, allowFailure, callData)
cast call "$MULTICALL3" \
"aggregate3((address,bool,bytes)[])(((bool,bytes)[]))" \
"[($TOKEN1,false,$CALL1),($TOKEN2,false,$CALL2),($TOKEN2,false,$CALL3)]" \
--rpc-url "$RPC_URL"
When to use: Prefer Multicall3 whenever you need 2+ read calls on the same chain. It reduces RPC round-trips and guarantees all results come from the same block.
Caveat: msg.sender in downstream calls becomes the Multicall3 contract address, not the caller. Only use for reads or calls where msg.sender doesn't matter.
Use cast mktx to create a signed raw transaction without broadcasting it.
cast mktx "$CONTRACT" "transfer(address,uint256)" "$TO" "$AMOUNT" \
--rpc-url "$RPC_URL" \
--private-key "$ETH_PRIVATE_KEY"
# View transaction details
cast tx "$TX_HASH" --rpc-url "$RPC_URL"
# View transaction receipt
cast receipt "$TX_HASH" --rpc-url "$RPC_URL"
# Get specific receipt fields
cast receipt "$TX_HASH" status --rpc-url "$RPC_URL"
cast receipt "$TX_HASH" gasUsed --rpc-url "$RPC_URL"
# Encode a function call
cast calldata "transfer(address,uint256)" "$TO" "$AMOUNT"
# ABI-encode arguments (without function selector)
cast abi-encode "transfer(address,uint256)" "$TO" "$AMOUNT"
# Decode calldata with a known signature
cast decode-calldata "transfer(address,uint256)" "$CALLDATA"
# Decode ABI-encoded data (without selector)
cast abi-decode "balanceOf(address)(uint256)" "$DATA"
# Get the 4-byte selector for a function
cast sig "transfer(address,uint256)"
# Get the event topic hash
cast sig-event "Transfer(address,address,uint256)"
# Generate a new wallet
cast wallet new
# Get address from private key
cast wallet address --private-key "$ETH_PRIVATE_KEY"
# List keystore accounts
cast wallet list
# Sign a message
cast wallet sign "Hello, world!" --private-key "$ETH_PRIVATE_KEY"
# Resolve ENS name to address
cast resolve-name "vitalik.eth" --rpc-url "$RPC_URL"
# Reverse lookup: address to ENS name
cast lookup-address "$ADDR" --rpc-url "$RPC_URL"
# Get ETH balance
cast balance "$ADDR" --rpc-url "$RPC_URL"
# Get balance in ether (human-readable)
cast balance "$ADDR" --ether --rpc-url "$RPC_URL"
When the user specifies a chain by name, resolve the chain ID using these steps:
$evm-chains first — it is the authoritative Sablier-SDK-backed dataset for chain names, IDs, default public RPCs, native currency symbols, and RouteMesh support$evm-chains is unavailable, tell the user to install this collection with npx skills add PaulRBerg/agent-skills, then use references/chains.md as a limited fallback for common networks| Operation | Command | Key Flags |
|---|---|---|
| Send tx | cast send | --rpc-url, --private-key, --value |
| Read state | cast call | --rpc-url, --block |
| View tx | cast tx |
$evm-chains — Preferred source for Sablier SDK EVM chain data and RouteMesh supportWeekly Installs
95
Repository
GitHub Stars
41
First Seen
Feb 12, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykFail
Installed on
claude-code89
codex84
opencode84
gemini-cli83
github-copilot83
amp83
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
122,000 周安装
--rpc-url, --json |
| View receipt | cast receipt | --rpc-url, --json |
| Build tx | cast mktx | --rpc-url, --private-key |
| Encode call | cast calldata | (function sig + args) |
| Decode call | cast decode-calldata | (function sig + data) |
| ABI encode | cast abi-encode | (function sig + args) |
| ABI decode | cast abi-decode | (function sig + data) |
| Function sig | cast sig | (function signature string) |
| Batch reads | cast call Multicall3 | aggregate3, --rpc-url |
| Balance | cast balance | --rpc-url, --ether |
| ENS resolve | cast resolve-name | --rpc-url |
| New wallet | cast wallet new | — |
| Sign message | cast wallet sign | --private-key, --account |