名称: typhoon-starknet-account
描述: 通过 Typhoon 创建匿名 Starknet 钱包并与 Starknet 合约交互。为需要匿名的智能体提供隐私优先的钱包创建方案。
许可证: Apache-2.0
元数据: {"author":"starknet-agentic","version":"1.0.0","org":"keep-starknet-strange"}
关键词: [starknet, wallet, anonymous, transfer, balance, anonymous-agent-wallet, strk, eth, privacy, typhoon]
允许工具: [Bash, Read, Write, Glob, Grep, Task]
user-invocable: true
本技能提供面向智能体的脚本,用于:
- 创建/加载 Starknet 账户(Typhoon 流程)
- 发现 ABI / 函数
- 读取和写入合约
- 预执行检查(模拟 + 费用估算)
- 使用人类可读金额进行授权检查
npm install starknet@^9.2.1 typhoon-sdk@^1.1.13 @andersmyrmel/vard@^1.2.0 @avnu/avnu-sdk compromise@^14.14.5 ws@^8.19.0
这些脚本通过 JSON-RPC 与 Starknet 通信。请配置以下选项之一:
STARKNET_RPC_URL(推荐),或rpcUrl。如果两者均未提供,脚本将回退到公共 Lava 主网 RPC:
- https://rpc.starknet.lava.build:443
import { RpcProvider, Account, Contract } from 'starknet';
const provider = new RpcProvider({
nodeUrl: process.env.STARKNET_RPC_URL || 'https://rpc.starknet.lava.build:443'
});
// 签名者可以是私钥字符串或 Starknet Signer 实例
const account = new Account({
provider,
address: process.env.ACCOUNT_ADDRESS,
signer: process.env.PRIVATE_KEY
});
const contract = new Contract(abi, contractAddress, account);
// 读取
const balance = await contract.call('balance_of', [account.address]);
// 写入(签名 -> 发送 -> 等待)
const tx = await contract.invoke('transfer', [to, amount], { waitForTransaction: false });
const receipt = await provider.waitForTransaction(tx.transaction_hash);
常用调用:
- provider.getBlock('latest')
- provider.callContract({ contractAddress, entrypoint, calldata })
- provider.getClassAt(contractAddress)
RPC_UNAVAILABLE → 检查 STARKNET_RPC_URL,确认网络可达性,使用退避策略重试。INVALID_ADDRESS → 验证 0x... 地址格式以及预期的网络/账户。INSUFFICIENT_FUNDS → 在执行写入调用前检查 STRK/代币余额;减少金额或充值。CONTRACT_CALL_FAILURE → 先运行读取/模拟,记录合约/方法/调用数据,仅对瞬态 RPC 错误进行重试。EXEC:node scripts/parse-smart.js '{"prompt":"STRING"}'
输出(成功):
{
"success": true,
"security": {"safe": true},
"tokens": ["ETH","STRK"],
"tokenMap": {"STRK":{"address":"0x...","decimals":18}},
"protocols": ["Ekubo","AVNU"],
"abis": {"Ekubo":["swap"],"AVNU":["swap"]},
"addresses": {"Ekubo":"0x...","AVNU":"0x01"}
}
输出(无账户):
{
"success": true,
"canProceed": false,
"needsAccount": true,
"operationType": "NO_ACCOUNT",
"noAccountGuide": {"steps": [...]},
"nextStep": "CREATE_ACCOUNT_REQUIRED"
}
输出(账户创建意图):
{
"success": true,
"canProceed": false,
"operationType": "CREATE_ACCOUNT_INTENT",
"hasAccount": true|false,
"noAccountGuide": {"steps": [...]},
"nextStep": "ACCOUNT_ALREADY_EXISTS|CREATE_ACCOUNT_REQUIRED"
}
LLM 构建:
{
"parsed": {
"operations": [{"action":"swap","protocol":"AVNU","tokenIn":"ETH","tokenOut":"STRK","amount":10}],
"operationType": "WRITE|READ|EVENT_WATCH|CONDITIONAL",
"tokenMap": {...},
"abis": {...},
"addresses": {...}
}
}
EXEC:node scripts/resolve-smart.js '{"parsed":{...}}'
输出(需要授权):
{
"canProceed": true,
"nextStep": "USER_AUTHORIZATION",
"authorizationDetails": {"prompt":"是否授权? (yes/no)"},
"executionPlan": {"requiresAuthorization": true}
}
规则:
nextStep == "USER_AUTHORIZATION",则向用户请求明确确认。WRITE/CONDITIONAL 的 AVNU SDK 标准流程:
RpcProvider + Account)。本技能中典型的 AVNU SDK 调用:
- fetchTokens(...)
- getQuotes(...)
- executeSwap(...)
{
"watchers": [{
"action": "swap",
"protocol": "AVNU",
"tokenIn": "STRK",
"tokenOut": "ETH",
"amount": 10,
"condition": {
"eventName": "Swapped",
"protocol": "Ekubo",
"timeConstraint": {"amount":5,"unit":"minutes"}
}
}]
}
时间约束 → 创建定时任务,并设置 TTL 自动清理。