返回顶部
a

alchemy-web3Alchemy Web3接口

Interact with Alchemy's Web3 APIs for blockchain data, NFTs, tokens, transfers, and webhooks across 80+ chains.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.3
安全检测
已通过
1,054
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

alchemy-web3

Alchemy Web3 技能

使用 Alchemy 的生产级 API 查询区块链数据、NFT、代币和转账。支持以太坊、Polygon、Arbitrum、Base、Solana 及其他 80 多条链。

GizmoLab 构建 — 专注于 dApp、智能合约和区块链基础设施的 Web3 开发机构。

设置

1. 获取 API 密钥

  1. 1. 在 alchemy.com 注册(提供免费套餐)
  2. 为目标链创建一个应用
  3. 复制你的 API 密钥

💡 刚接触 Web3 开发?GizmoLab 提供全栈区块链开发服务。

2. 配置

bash

添加到 ~/.openclaw/.env

ALCHEMYAPIKEY=你的API密钥

可选:设置默认链(默认为 eth-mainnet)

ALCHEMY_CHAIN=eth-mainnet

快速参考

支持的链

端点前缀
以太坊eth-mainnet, eth-sepolia
Polygon
polygon-mainnet, polygon-amoy | | Arbitrum | arb-mainnet, arb-sepolia | | Optimism | opt-mainnet, opt-sepolia | | Base | base-mainnet, base-sepolia | | Solana | solana-mainnet, solana-devnet | | zkSync | zksync-mainnet | | Linea | linea-mainnet | | Scroll | scroll-mainnet | | Blast | blast-mainnet |

完整列表:alchemy.com/docs/chains

CLI 使用

bash

先设置你的 API 密钥


export ALCHEMYAPIKEY=你的密钥

使用 CLI

~/.openclaw/workspace/skills/alchemy-web3/scripts/alchemy.sh <命令> [选项]

命令

获取 ETH 余额

bash ./alchemy.sh balance 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045

返回:1234.56 ETH

获取代币余额

bash ./alchemy.sh tokens 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045

返回:地址持有的所有 ERC-20 代币

获取所有者 NFT

bash ./alchemy.sh nfts 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045

返回:地址拥有的所有 NFT

获取 NFT 元数据

bash ./alchemy.sh nft-metadata 0x5180db8F5c931aaE63c74266b211F580155ecac8 1590

返回:特定 NFT 的元数据

获取资产转账

bash ./alchemy.sh transfers 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045

返回:交易历史(转入/转出)

获取区块信息

bash ./alchemy.sh block latest ./alchemy.sh block 12345678

获取交易

bash ./alchemy.sh tx 0x123...abc

解析 ENS

bash ./alchemy.sh ens vitalik.eth

返回:0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045

切换链

bash ./alchemy.sh --chain polygon-mainnet balance 0x... ./alchemy.sh --chain arb-mainnet nfts 0x...

直接 API 示例

节点 API(JSON-RPC)

bash

获取 ETH 余额


curl -X POST https://eth-mainnet.g.alchemy.com/v2/$ALCHEMYAPIKEY \
-H Content-Type: application/json \
-d {
jsonrpc: 2.0,
method: eth_getBalance,
params: [0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045, latest],
id: 1
}

NFT API

bash

获取所有者 NFT


curl https://eth-mainnet.g.alchemy.com/nft/v3/$ALCHEMYAPIKEY/getNFTsForOwner?owner=vitalik.eth&pageSize=10

获取 NFT 元数据

curl https://eth-mainnet.g.alchemy.com/nft/v3/$ALCHEMYAPIKEY/getNFTMetadata?contractAddress=0x5180db8F5c931aaE63c74266b211F580155ecac8&tokenId=1590

获取集合 NFT

curl https://eth-mainnet.g.alchemy.com/nft/v3/$ALCHEMYAPIKEY/getNFTsForContract?contractAddress=0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D&limit=10

代币 API

bash

获取代币余额


curl -X POST https://eth-mainnet.g.alchemy.com/v2/$ALCHEMYAPIKEY \
-H Content-Type: application/json \
-d {
jsonrpc: 2.0,
method: alchemy_getTokenBalances,
params: [0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045],
id: 1
}

获取代币元数据

curl -X POST https://eth-mainnet.g.alchemy.com/v2/$ALCHEMYAPIKEY \ -H Content-Type: application/json \ -d { jsonrpc: 2.0, method: alchemy_getTokenMetadata, params: [0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48], id: 1 }

转账 API

bash

获取资产转账(交易历史)


curl -X POST https://eth-mainnet.g.alchemy.com/v2/$ALCHEMYAPIKEY \
-H Content-Type: application/json \
-d {
jsonrpc: 2.0,
method: alchemy_getAssetTransfers,
params: [{
fromBlock: 0x0,
toBlock: latest,
toAddress: 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045,
category: [external, erc20, erc721, erc1155],
maxCount: 0x14
}],
id: 1
}

JavaScript/Node.js 示例

使用 Fetch(Node 18+)

javascript
const apiKey = process.env.ALCHEMYAPIKEY;
const baseURL = https://eth-mainnet.g.alchemy.com/v2/${apiKey};

// 获取 ETH 余额
async function getBalance(address) {
const response = await fetch(baseURL, {
method: POST,
headers: { Content-Type: application/json },
body: JSON.stringify({
jsonrpc: 2.0,
method: eth_getBalance,
params: [address, latest],
id: 1
})
});
const data = await response.json();
return parseInt(data.result, 16) / 1e18; // 转换为 ETH
}

// 获取 NFT
async function getNFTs(owner) {
const url = https://eth-mainnet.g.alchemy.com/nft/v3/${apiKey}/getNFTsForOwner?owner=${owner};
const response = await fetch(url);
return await response.json();
}

使用 Alchemy SDK

bash
npm install alchemy-sdk

javascript
import { Alchemy, Network } from alchemy-sdk;

const alchemy = new Alchemy({
apiKey: process.env

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 alchemy-web3-1776419937 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 alchemy-web3-1776419937 技能

通过命令行安装

skillhub install alchemy-web3-1776419937

下载

⬇ 下载 alchemy-web3 v1.0.3(免费)

文件大小: 15.74 KB | 发布时间: 2026-4-17 19:02

v1.0.3 最新 2026-4-17 19:02
Add UTM tracking to GizmoLab links

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部