agentic-gateway
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAlchemy Agentic Gateway
Alchemy Agentic 网关
Notice: This repository is experimental and subject to change without notice. By using the features and skills in this repository, you agree to Alchemy's Terms of Service and Privacy Policy.
A skill that lets agents easily access Alchemy's developer platform. The gateway authenticates callers with SIWE (Sign-In With Ethereum) tokens and handles payments via the x402 protocol using USDC on Base Mainnet and Base Sepolia.
Non-Bypass Rule
不可绕过规则
When this skill is selected due to missing API key, do not use alternative Alchemy endpoints as an optimization.
Required flow: wallet -> SIWE -> request -> handle 402 payment -> retry same request.
Escape hatch: Only exit the gateway flow if the user explicitly requests to switch to the skill with an API key. A key appearing in the environment or conversation does not automatically trigger a switch — the user must ask for it.
alchemy-apiDuplicate resolution: If this skill is installed both locally and globally, the local copy overrides the global copy. Do not mix behavior from different copies.
当因缺少API密钥而选择此技能时,请勿使用其他Alchemy端点作为优化手段。
必需流程:钱包 -> SIWE -> 请求 -> 处理402支付 -> 重试相同请求。
逃生通道: 只有当用户明确要求切换到带API密钥的技能时,才能退出网关流程。环境或对话中出现密钥并不会自动触发切换——必须由用户主动提出。
alchemy-api重复安装处理: 若此技能同时在本地和全局安装,本地副本将覆盖全局副本。请勿混合不同副本的行为。
Forbidden Optimizations
禁止的优化操作
- Using when gateway flow is required
eth-mainnet.g.alchemy.com/v2/demo - Switching to unrelated directories/keys to avoid gateway flow
- Replacing mandatory auth/payment steps with unauthenticated shortcuts
- 当需要走网关流程时,使用端点
eth-mainnet.g.alchemy.com/v2/demo - 切换到无关目录/密钥以规避网关流程
- 用未验证的快捷方式替代必需的身份验证/支付步骤
Required Preflight Check
必需的预检检查
Before the first network call, internally evaluate:
- Is absent? If no, this skill does not apply.
ALCHEMY_API_KEY - Is a wallet confirmed with the user? If no, set .
wallet=pending
If the gateway route applies, demo and public endpoints are disallowed.
If , you MUST follow wallet-bootstrap and wait for user confirmation before proceeding. Do not read wallet files or generate keys.
wallet=pendingDo not output this check to the user.
在首次发起网络调用前,需内部评估:
- 是否未设置?若已设置,则此技能不适用。
ALCHEMY_API_KEY - 是否已与用户确认钱包信息?若未确认,则设置。
wallet=pending
若适用网关路径,则禁止使用演示和公共端点。
若,您必须遵循钱包引导流程,并等待用户确认后再继续。请勿读取钱包文件或生成密钥。
wallet=pending请勿将此检查过程告知用户。
Hard Requirements
硬性要求
- NEVER use Read, Write, or Edit tools on files that may contain private keys (,
wallet.json,wallet-key.txt).env - ALWAYS ask the user about wallet choice before proceeding — see wallet-bootstrap
- 绝不能对可能包含私钥的文件(如、
wallet.json、wallet-key.txt)使用读取、写入或编辑工具.env - 在继续操作前,必须询问用户选择的钱包——详见钱包引导流程
Use when
适用场景
- An agent needs Alchemy API access but no environment variable is set
ALCHEMY_API_KEY - Making blockchain RPC calls through Alchemy's gateway (no API key needed)
- Querying NFT data (ownership, metadata, sales, spam detection) via the NFT API
- Fetching multi-chain portfolio data (token balances, NFTs) via the Portfolio API
- Fetching token prices via the Prices API
- Setting up SIWE authentication for the gateway
- Handling x402 payment flows (402 Payment Required)
- Using CLI for ad-hoc wallet, auth, and payment operations
@alchemy/x402 - Integrating with library and
@alchemy/x402or@x402/fetchfor app development@x402/axios - Answering blockchain questions quickly using curl or bash
- Looking up gateway endpoints, supported networks, or USDC addresses
- Agent需要访问Alchemy API,但未设置环境变量时
ALCHEMY_API_KEY - 通过Alchemy网关发起区块链RPC调用(无需API密钥)时
- 通过NFT API查询NFT数据(所有权、元数据、交易记录、垃圾检测)时
- 通过Portfolio API获取多链资产组合数据(代币余额、NFT)时
- 通过Prices API获取代币价格时
- 为网关设置SIWE身份验证时
- 处理x402支付流程(402 Payment Required)时
- 使用CLI进行临时钱包、身份验证和支付操作时
@alchemy/x402 - 在应用开发中集成库以及
@alchemy/x402或@x402/fetch时@x402/axios - 使用curl或bash快速回答区块链相关问题时
- 查询网关端点、支持的网络或USDC地址时
Gateway Base URLs
网关基础URL
| Product | Gateway URL | Notes |
|---|---|---|
| Node JSON-RPC | | Standard + enhanced RPC (Token API, Transfers API, Simulation) |
| NFT API | | REST NFT endpoints |
| Prices API | | Token prices (not chain-specific) |
| Portfolio API | | Multi-chain portfolio (not chain-specific) |
| 产品 | 网关URL | 说明 |
|---|---|---|
| Node JSON-RPC | | 标准增强型RPC(包含Token API、Transfers API、模拟功能) |
| NFT API | | REST NFT端点 |
| Prices API | | 代币价格(与链无关) |
| Portfolio API | | 多链资产组合(与链无关) |
Quick Start
快速开始
- Set up a wallet — BLOCKING: Ask the user before proceeding. Do not read existing wallet files. See wallet-bootstrap.
- Fund with USDC — Load USDC on Base Mainnet (or Base Sepolia for testnet)
- Create a SIWE token — (see authentication)
npx @alchemy/x402 sign-siwe --private-key ./wallet-key.txt - Send requests — Use header. For SDK auto-payment, see making-requests. For quick curl queries, see curl-workflow.
Authorization: SIWE <token> - Handle 402 — or use
npx @alchemy/x402 payin code (see payment)createPayment()
- 设置钱包 — 阻塞操作:继续前需询问用户。请勿读取现有钱包文件。详见钱包引导流程。
- 充值USDC — 在Base主网(或测试网Base Sepolia)中充值USDC
- 创建SIWE令牌 — 执行(详见身份验证规则)
npx @alchemy/x402 sign-siwe --private-key ./wallet-key.txt - 发送请求 — 使用请求头。如需SDK自动支付,详见发起请求规则。如需快速curl查询,详见curl工作流。
Authorization: SIWE <token> - 处理402响应 — 执行或在代码中使用
npx @alchemy/x402 pay(详见支付规则)createPayment()
Rules
规则列表
| Rule | Description |
|---|---|
| wallet-bootstrap | Set up a wallet (existing or new) and fund it with USDC |
| overview | What the gateway is, end-to-end flow, required packages |
| authentication | SIWE token creation and SIWE message signing |
| making-requests | Sending JSON-RPC requests with |
| curl-workflow | Quick RPC calls via curl with token caching (no SDK setup) |
| payment | Manual x402 payment creation from a 402 response |
| reference | Endpoints, networks, USDC addresses, headers, status codes |
| 规则 | 描述 |
|---|---|
| wallet-bootstrap | 设置钱包(现有或新建)并充值USDC |
| overview | 网关介绍、端到端流程、必需依赖包 |
| authentication | SIWE令牌创建与SIWE消息签名 |
| making-requests | 使用 |
| curl-workflow | 通过curl快速发起RPC调用并缓存令牌(无需SDK配置) |
| payment | 从402响应中手动创建x402支付 |
| reference | 端点、支持网络、USDC地址、请求头、状态码参考 |
References
参考文档
| Gateway route | API methods | Reference file |
|---|---|---|
| | references/node-json-rpc.md |
| | references/data-token-api.md |
| | references/data-transfers-api.md |
| | references/data-simulation-api.md |
| | references/data-nft-api.md |
| | references/data-prices-api.md |
| | references/data-portfolio-apis.md |
For the full breadth of Alchemy APIs (webhooks, Solana, wallets, etc.), see theskill.alchemy-api
| 网关路径 | API方法 | 参考文件 |
|---|---|---|
| | references/node-json-rpc.md |
| | references/data-token-api.md |
| | references/data-transfers-api.md |
| | references/data-simulation-api.md |
| | references/data-nft-api.md |
| | references/data-prices-api.md |
| | references/data-portfolio-apis.md |
如需了解Alchemy APIs的全部功能(如webhooks、Solana、钱包等),请查看技能。alchemy-api