关于 Bankr Dev - Arbitrary Transactions
Bankr Dev - Arbitrary Transactions 是通过 Bankr API 提交原始 EVM 交易的开发技能,适用于需要直接调用合约的开发者。它允许指定目标地址、calldata、转账金额和链 ID。
主要功能
- 01提交预构建 calldata
- 02执行自定义合约调用
- 03附带 calldata 转移代币
- 04指定目标链和交易参数
适用场景
- 01提交编码好的合约交易
- 02调用合约函数
- 03转账时同时执行 calldata
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ bankrbot/ claude-plugins --skill bankr-dev---arbitrary-transactions安装后在 Claude Code 中输入/bankr-dev---arbitrary-transactions确认已加载。
详细介绍
任意交易能力
通过 Bankr API 使用显式调用数据提交原始 EVM 交易。
你可以执行的操作
| 操作 | 描述 |
|---|---|
| 提交调用数据 | 在任何受支持的链上执行预构建的调用数据 |
| 自定义合约调用 | 使用原始函数调用与任何合约交互 |
| 携带数据的价值转账 | 在执行调用数据的同时发送 ETH/MATIC |
JSON Schema
{
"to": "0x...",
"data": "0x...",
"value": "0",
"chainId": 8453
}
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
to | string | 是 | 合约地址(0x + 40 个十六进制字符) |
data | string | 是 | 调用数据(0x + 十六进制内容;为空时使用 "0x") |
value | string | 是 | 以字符串表示的 Wei 数量 |
chainId | number | 是 | 目标链(1、137 或 8453) |
支持的链
| 链 | Chain ID |
|---|---|
| Ethereum | 1 |
| Polygon | 137 |
| Base | 8453 |
| Unichain | 130 |
用法
import { execute } from "./bankr-client";
// Submit arbitrary transaction
const txJson = {
to: "0x1234567890abcdef1234567890abcdef12345678",
data: "0xa9059cbb...",
value: "0",
chainId: 8453
};
await execute(`Submit this transaction: ${JSON.stringify(txJson)}`);
集成模式
import { execute } from "./bankr-client";
interface ArbitraryTx {
to: string;
data: string;
value: string;
chainId: number;
}
async function submitArbitraryTx(tx: ArbitraryTx): Promise<void> {
// Validate before submission
if (!tx.to.match(/^0x[a-fA-F0-9]{40}$/)) {
throw new Error("Invalid address format");
}
if (!tx.data.startsWith("0x")) {
throw new Error("Calldata must start with 0x");
}
if (![1, 137, 8453, 130].includes(tx.chainId)) {
throw new Error("Unsupported chain");
}
const prompt = `Submit this transaction: ${JSON.stringify(tx)}`;
await execute(prompt);
}
// Example: ERC-20 transfer
await submitArbitraryTx({
to: "0xTokenContractAddress...",
data: "0xa9059cbb000000000000000000000000...", // transfer(address,uint256)
value: "0",
chainId: 8453
});
错误处理
try {
await submitArbitraryTx(tx);
} catch (error) {
if (error.message.includes("reverted")) {
// Transaction reverted - check calldata encoding
console.error("Transaction reverted:", error);
} else if (error.message.includes("insufficient")) {
// Not enough funds for gas + value
console.error("Insufficient funds:", error);
} else if (error.message.includes("unsupported")) {
// Chain not supported
console.error("Unsupported chain:", error);
}
}
相关技能
bankr-client-patterns- 客户端设置和 execute 函数bankr-api-basics- API 基础知识bankr-token-trading- 更高级别的交易操作
评论
支持 Markdown