bankr-x402-sdk---token-swaps by bankrbot/claude-plugins
npx skills add https://github.com/bankrbot/claude-plugins --skill 'Bankr x402 SDK - Token Swaps'通过 AI 驱动的 0x 路由构建并执行代币兑换。
| 模式 | 示例 |
|---|---|
| 基于数量 | "Swap 0.1 ETH to USDC" |
| 基于价值 | "Buy $100 worth of DEGEN" |
| 百分比 | "Swap 50% of my ETH to USDC" |
| 全部卖出 | "Sell all my DEGEN" |
| 特定链 | "Swap ETH to USDC on Polygon" |
# 数量兑换
"Swap 0.1 ETH to USDC"
"Exchange 100 USDC for WETH"
"Swap 1000 DEGEN to ETH"
# 价值兑换
"Buy $100 worth of DEGEN"
"Purchase $50 of ETH"
# 百分比兑换
"Swap 50% of my ETH to USDC"
"Sell 25% of my DEGEN"
# 特定链兑换
"Swap 0.1 ETH to USDC on Base"
"Exchange 100 USDC for WETH on Ethereum"
对于 ERC20 兑换(卖出 ETH 以外的代币),在兑换前需要授权。
const result = await client.promptAndWait({
prompt: "Swap 100 USDC to WETH",
});
const swapTx = result.transactions?.find(tx => tx.type === "swap");
// 检查是否需要授权
if (swapTx?.metadata.approvalRequired) {
// 首先执行预构建的授权交易
await wallet.sendTransaction(swapTx.metadata.approvalTx);
}
// 然后执行兑换
await wallet.sendTransaction(swapTx.metadata.transaction);
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 字段 | 描述 |
|---|---|
approvalRequired | 兑换前是否需要授权 |
approvalTx | 预构建的授权交易(准备发送) |
allowanceTarget | 0x AllowanceHolder 地址(用于手动授权) |
import { BankrClient } from "@bankr/sdk";
const client = new BankrClient({
privateKey: process.env.BANKR_PRIVATE_KEY as `0x${string}`,
});
const result = await client.promptAndWait({
prompt: "Swap 0.1 ETH to USDC on Base",
});
if (result.status === "completed" && result.transactions?.length) {
const tx = result.transactions[0].metadata.transaction;
await wallet.sendTransaction(tx);
}
| 链 | 原生代币 | 默认 |
|---|---|---|
| Base | ETH | 是 |
| Ethereum | ETH | 否 |
| Polygon | MATIC | 否 |
| Solana | SOL | 否 |
每周安装量
0
代码仓库
GitHub 星标数
70
首次出现时间
1970年1月1日
Build and execute token swaps with AI-powered 0x routing.
| Pattern | Example |
|---|---|
| Amount-based | "Swap 0.1 ETH to USDC" |
| Value-based | "Buy $100 worth of DEGEN" |
| Percentage | "Swap 50% of my ETH to USDC" |
| Sell all | "Sell all my DEGEN" |
| Chain-specific | "Swap ETH to USDC on Polygon" |
# Amount Swaps
"Swap 0.1 ETH to USDC"
"Exchange 100 USDC for WETH"
"Swap 1000 DEGEN to ETH"
# Value Swaps
"Buy $100 worth of DEGEN"
"Purchase $50 of ETH"
# Percentage Swaps
"Swap 50% of my ETH to USDC"
"Sell 25% of my DEGEN"
# Chain-Specific
"Swap 0.1 ETH to USDC on Base"
"Exchange 100 USDC for WETH on Ethereum"
For ERC20 swaps (selling tokens other than ETH), approval is required before the swap.
const result = await client.promptAndWait({
prompt: "Swap 100 USDC to WETH",
});
const swapTx = result.transactions?.find(tx => tx.type === "swap");
// Check if approval is needed
if (swapTx?.metadata.approvalRequired) {
// Execute pre-built approval transaction first
await wallet.sendTransaction(swapTx.metadata.approvalTx);
}
// Then execute the swap
await wallet.sendTransaction(swapTx.metadata.transaction);
| Field | Description |
|---|---|
approvalRequired | Whether approval needed before swap |
approvalTx | Pre-built approval transaction (ready to send) |
allowanceTarget | 0x AllowanceHolder address (for manual approval) |
import { BankrClient } from "@bankr/sdk";
const client = new BankrClient({
privateKey: process.env.BANKR_PRIVATE_KEY as `0x${string}`,
});
const result = await client.promptAndWait({
prompt: "Swap 0.1 ETH to USDC on Base",
});
if (result.status === "completed" && result.transactions?.length) {
const tx = result.transactions[0].metadata.transaction;
await wallet.sendTransaction(tx);
}
| Chain | Native Token | Default |
|---|---|---|
| Base | ETH | Yes |
| Ethereum | ETH | No |
| Polygon | MATIC | No |
| Solana | SOL | No |
Weekly Installs
0
Repository
GitHub Stars
70
First Seen
Jan 1, 1970
飞书OpenAPI Explorer:探索和调用未封装的飞书原生API接口
23,400 周安装