Agent Wallet
Use this skill to safely create a wallet the agent can use for transfers, swaps, and any EVM chain transaction without ever exposing private keys to the agent. Create a wallet, set spending policies, and your agent can transfer tokens, do swaps, and interact with smart contracts within the boundaries you define.
The agent never sees the private key. All transactions are executed server-side through a smart account. The wallet owner controls what the agent can do via configurable policies.
Configuration
- - Base API URL: Use the
SAFESKILLS_API_URL environment variable if set, otherwise default to INLINECODE1 - Frontend URL: Use the
SAFESKILLS_FRONTEND_URL environment variable if set, otherwise default to INLINECODE3
All API requests require a Bearer token (the API key returned when creating a wallet).
CODEBLOCK0
Quick Start
1. Create a Wallet
Create a new smart account wallet for your agent. This generates a private key server-side (you never see it), creates a ZeroDev smart account, and returns an API key for the agent plus a claim URL for the wallet owner.
CODEBLOCK1
Response includes:
- -
apiKey -- store this securely; use it as the Bearer token for all future requests - INLINECODE5 -- share this with the user so they can claim the wallet and set policies
- INLINECODE6 -- the smart account address
After creating, tell the user:
"Here is your wallet claim URL: <claimUrl>. Use this to claim ownership, set spending policies, and monitor your agent's wallet activity."
2. Get Wallet Address
CODEBLOCK2
3. Check Balances
CODEBLOCK3
4. Transfer ETH or Tokens
CODEBLOCK4
5. Swap Tokens
Swap one token for another using DEX liquidity (powered by 0x).
CODEBLOCK5
- -
sellToken / buyToken: Token contract addresses. Use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE for native ETH. - INLINECODE11 : Human-readable amount to sell (e.g.
"0.1" for 0.1 ETH). - INLINECODE13 : The chain to swap on (1 = Ethereum, 137 = Polygon, 42161 = Arbitrum, 10 = Optimism, 8453 = Base, etc.).
- INLINECODE14 : Optional slippage tolerance in basis points (100 = 1%). Defaults to 100.
The preview endpoint returns expected buy amount, route info, and fees without executing. The execute endpoint performs the actual swap through the smart account, handling ERC20 approvals automatically.
6. Send Arbitrary Transaction
Interact with any smart contract by sending custom calldata.
CODEBLOCK6
Policies
The wallet owner controls what the agent can do by setting policies via the claim URL. If a transaction violates a policy, the API will reject it or require human approval via Telegram.
| Policy | What it does |
|---|
| Address allowlist | Only allow transfers/calls to specific addresses |
| Token allowlist |
Only allow transfers of specific ERC-20 tokens |
|
Function allowlist | Only allow calling specific contract functions (by 4-byte selector) |
|
Spending limit (per tx) | Max USD value per transaction |
|
Spending limit (daily) | Max USD value per rolling 24 hours |
|
Spending limit (weekly) | Max USD value per rolling 7 days |
|
Require approval | Every transaction needs human approval via Telegram |
|
Approval threshold | Transactions above a USD amount need human approval |
If no policies are set, all actions are allowed by default. Once the owner claims the wallet and adds policies, the agent operates within those boundaries.
Important Notes
- - Never try to access raw secret values. The private key stays server-side -- that's the whole point.
- Always store the API key from wallet creation -- it's the only way to authenticate.
- Always share the claim URL with the user after creating a wallet.
- The default chain ID is
84532 (Base Sepolia testnet). Adjust as needed. - If a transaction is rejected, it may be blocked by a policy. Tell the user to check their policy settings via the claim URL.
- If a transaction requires approval, it will return
status: "pending_approval". The wallet owner will receive a Telegram notification to approve or deny.
Agent Wallet
使用此技能可安全创建代理钱包,用于转账、兑换及任何EVM链交易,且无需向代理暴露私钥。创建钱包、设置支出策略后,代理即可在您定义的范围内进行代币转账、兑换及智能合约交互。
代理永远不会看到私钥。 所有交易均通过智能账户在服务端执行。钱包所有者可通过可配置策略控制代理的操作权限。
配置
- - 基础API地址: 若设置了SAFESKILLSAPIURL环境变量则使用该值,否则默认为https://safeskill-production.up.railway.app
- 前端地址: 若设置了SAFESKILLSFRONTENDURL环境变量则使用该值,否则默认为https://safeskill-production.up.railway.app
所有API请求都需要Bearer令牌(创建钱包时返回的API密钥)。
Authorization: Bearer
快速开始
1. 创建钱包
为代理创建新的智能账户钱包。此操作会在服务端生成私钥(您永远看不到),创建ZeroDev智能账户,并返回代理的API密钥及钱包所有者的认领链接。
bash
curl -X POST ${SAFESKILLSAPIURL:-https://safeskill-production.up.railway.app}/api/secrets \
-H Content-Type: application/json \
-d {
type: EVM_WALLET,
memo: 我的代理钱包,
chainId: 84532
}
响应包含:
- - apiKey -- 请安全存储;用作所有后续请求的Bearer令牌
- claimUrl -- 将此链接分享给用户,以便其认领钱包并设置策略
- address -- 智能账户地址
创建后,告知用户:
这是您的钱包认领链接:。请使用此链接认领所有权、设置支出策略并监控代理钱包活动。
2. 获取钱包地址
bash
curl -X GET ${SAFESKILLSAPIURL:-https://safeskill-production.up.railway.app}/api/skills/evm-wallet/address \
-H Authorization: Bearer
3. 查询余额
bash
仅查询原生代币余额
curl -X GET ${SAFESKILLS
APIURL:-https://safeskill-production.up.railway.app}/api/skills/evm-wallet/balance \
-H Authorization: Bearer
查询含ERC-20代币的余额
curl -X GET ${SAFESKILLSAPIURL:-https://safeskill-production.up.railway.app}/api/skills/evm-wallet/balance?tokens=0xTokenAddr1,0xTokenAddr2 \
-H Authorization: Bearer
4. 转账ETH或代币
bash
转账原生ETH
curl -X POST ${SAFESKILLSAPIURL:-https://safeskill-production.up.railway.app}/api/skills/evm-wallet/transfer \
-H Authorization: Bearer \
-H Content-Type: application/json \
-d {
to: 0xRecipientAddress,
amount: 0.01
}
转账ERC-20代币
curl -X POST ${SAFESKILLSAPIURL:-https://safeskill-production.up.railway.app}/api/skills/evm-wallet/transfer \
-H Authorization: Bearer \
-H Content-Type: application/json \
-d {
to: 0xRecipientAddress,
amount: 100,
token: 0xTokenContractAddress
}
5. 兑换代币
使用DEX流动性(由0x提供支持)兑换代币。
bash
预览兑换(仅查询价格,不执行)
curl -X POST ${SAFESKILLSAPIURL:-https://safeskill-production.up.railway.app}/api/skills/evm-wallet/swap/preview \
-H Authorization: Bearer \
-H Content-Type: application/json \
-d {
sellToken: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE,
buyToken: 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48,
sellAmount: 0.1,
chainId: 1
}
执行兑换
curl -X POST ${SAFESKILLSAPIURL:-https://safeskill-production.up.railway.app}/api/skills/evm-wallet/swap/execute \
-H Authorization: Bearer \
-H Content-Type: application/json \
-d {
sellToken: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE,
buyToken: 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48,
sellAmount: 0.1,
chainId: 1,
slippageBps: 100
}
- - sellToken / buyToken:代币合约地址。使用0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE表示原生ETH。
- sellAmount:人类可读的卖出数量(例如0.1表示0.1 ETH)。
- chainId:兑换链ID(1=以太坊,137=Polygon,42161=Arbitrum,10=Optimism,8453=Base等)。
- slippageBps:可选滑点容忍度,以基点为单位(100=1%)。默认值为100。
预览端点返回预期买入数量、路由信息和费用,不执行交易。执行端点通过智能账户执行实际兑换,自动处理ERC20授权。
6. 发送任意交易
通过发送自定义calldata与任何智能合约交互。
bash
curl -X POST ${SAFESKILLSAPIURL:-https://safeskill-production.up.railway.app}/api/skills/evm-wallet/send-transaction \
-H Authorization: Bearer \
-H Content-Type: application/json \
-d {
to: 0xContractAddress,
data: 0xCalldata,
value: 0
}
策略
钱包所有者通过认领链接设置策略来控制代理的操作权限。若交易违反策略,API将拒绝执行或要求通过Telegram进行人工审批。
| 策略 | 功能说明 |
|---|
| 地址白名单 | 仅允许向特定地址转账/调用 |
| 代币白名单 |
仅允许转账特定ERC-20代币 |
| 函数白名单 | 仅允许调用特定合约函数(按4字节选择器) |
| 单笔交易限额 | 每笔交易的最大美元价值 |
| 每日交易限额 | 每24小时滚动周期的最大美元价值 |
| 每周交易限额 | 每7天滚动周期的最大美元价值 |
| 需审批 | 每笔交易需通过Telegram人工审批 |
| 审批阈值 | 超过指定美元金额的交易需人工审批 |
若未设置任何策略,默认允许所有操作。一旦所有者认领钱包并添加策略,代理将在这些限制范围内运行。
重要提示
- - 切勿尝试访问原始密钥值。 私钥保留在服务端——这正是该方案的核心优势。
- 始终保存创建钱包时返回的API密钥——这是唯一的认证方式。
- 创建钱包后务必与用户分享认领链接。
- 默认链ID为84532(Base Sepolia测试网)。请根据实际需求调整。
- 若交易被拒绝,可能是被策略拦截。请告知用户通过认领链接检查策略设置。
- 若交易需要审批,将返回status: pending_approval。钱包所有者将收到Telegram通知进行批准或拒绝。