CornerStone MCP x402 Skill (for Agents)
This skill gives you (the agent) a set of tools to: create and manage Aptos and EVM wallets, check balances, and call x402-paid MCP tools (stock prediction, backtest, bank linking, agent/borrower scores). Payment is automatic — when a paid tool returns 402, the skill signs, verifies, settles, and retries transparently. You just call the tool; the result comes back.
Quick-start workflow
Follow this sequence on first use, then skip to the tool you need:
- 1. Check wallets → call
get_wallet_addresses (no args). - If empty → call
create_aptos_wallet then create_evm_wallet. - Fund → call
credit_aptos_wallet (Aptos faucet) and fund_evm_wallet (EVM faucet instructions). - Tell the user to whitelist the returned addresses at
https://arnstein.ch/flow.html. - Check balance → call
balance_aptos (must have USDC for predictions/backtests) and/or balance_evm (must have ETH for bank linking). - Use paid tools →
run_prediction, run_backtest, link_bank_account, or score tools.
Important: Paid tools will fail with a wallet/whitelist error if the address has not been funded and whitelisted. Always verify wallets and balances first.
Tool reference
Wallet management tools (local)
get_wallet_addresses
- - Args: none
- Returns:
{ aptos: [{ address, network }], evm: [{ address, network }] } — may be empty arrays. - When to use: Always call first before any wallet or paid tool action. Determines what exists.
- Decision: If both arrays are empty → create wallets. If only one is empty → create the missing one. If both have entries → proceed to balance check or paid tools.
create_aptos_wallet
- - Args:
{ force?: boolean, network?: "testnet" | "mainnet" } — defaults: force=false, network=testnet. - Returns:
{ success, address, network, message } or { success: false, message, addresses } if wallet exists and force=false. - When to use: When
get_wallet_addresses returns empty aptos array, or user requests a new wallet. - Error handling: If
success: false and wallet already exists, either use the existing wallet or retry with force: true to add another.
create_evm_wallet
- - Args:
{ force?: boolean, network?: "testnet" | "mainnet" } — defaults: force=false, network=testnet. - Returns:
{ success, address, network, message } or { success: false, message, addresses }. - Same pattern as
create_aptos_wallet.
credit_aptos_wallet
- - Args:
{ amount_octas?: number } — default 100,000,000 (= 1 APT). - Returns on devnet:
{ success: true, address } (programmatic faucet funded). - Returns on testnet:
{ success: true, address, faucet_url } (instructions only; no programmatic faucet). - Prerequisite: Aptos wallet must exist (
create_aptos_wallet first). - Note: Funded APT is for gas; tools pay in USDC (~6¢). The user may need to acquire testnet USDC separately.
fund_evm_wallet
- - Args: none
- Returns:
{ success: true, address, faucet_url, message } (manual funding instructions). - Prerequisite: EVM wallet must exist (
create_evm_wallet first). - Note: Returns a Base Sepolia faucet URL. The user must fund manually; there is no programmatic faucet.
Balance tools (local)
balance_aptos
- - Args: none
- Returns:
{ address, balances: { usdc, apt } } or { error }. - When to use: Before calling
run_prediction, run_backtest, or score tools to confirm sufficient USDC.
balance_evm
- - Args:
{ chain?: string } — default "base". Supported: base, baseSepolia, ethereum, polygon, arbitrum, optimism. - Returns:
{ address, chain, balance, symbol } or { error }. - When to use: Before calling
link_bank_account to confirm sufficient ETH on Base Sepolia. - Note: For testnet tools, use
chain: "baseSepolia".
Paid MCP tools (x402 — payment handled automatically)
All paid tools accept both Aptos and EVM payment. The skill picks the best option or follows PREFERRED_PAYMENT_ORDER. You never see 402 errors — just call the tool and get the result or an error message.
run_prediction
- - Args:
{ symbol: string, horizon?: number } — symbol is a stock ticker (e.g. "AAPL"), horizon is days (default 30). - Returns: Prediction result object (forecast data, confidence intervals, etc.) or
{ error }. - Cost: ~6¢ USDC (Aptos or EVM).
- Prerequisite: Funded + whitelisted Aptos or EVM wallet.
- Example call: INLINECODE55
run_backtest
- - Args:
{ symbol: string, startDate?: string, endDate?: string, strategy?: string } — dates in "YYYY-MM-DD", strategy defaults to "chronos". - Returns: Backtest result (returns, drawdown, sharpe, etc.) or
{ error }. - Cost: ~6¢ USDC.
- Example call: INLINECODE59
link_bank_account
- - Args: none
- Returns:
{ link_token } or account ID for Plaid bank linking, or { error }. - Cost: ~5¢ (EVM/Base).
- Prerequisite: Funded + whitelisted EVM wallet (Base Sepolia for testnet).
get_agent_reputation_score
- - Args:
{ agent_address?: string, payer_wallet?: string } — both optional; uses the configured wallet if omitted. - Returns:
{ reputation_score: number } (e.g. 100) or 403 if not allowlisted, or { error }. - Cost: ~6¢ via x402, or free with lender credits (pass
payer_wallet).
get_borrower_score
- - Args:
{ agent_address?: string, payer_wallet?: string } — same pattern. - Returns:
{ score: number } (100 base; higher with bank linked) or { error }. - Cost: ~6¢ via x402, or free with lender credits.
get_agent_reputation_score_by_email
- - Args:
{ email: string, payer_wallet?: string } — resolves email to allowlisted agent. - Returns:
{ reputation_score: number } or { error }. - Prerequisite:
SCORE_BY_EMAIL_ENABLED must be set on the server. Higher fee.
get_borrower_score_by_email
- - Args:
{ email: string, payer_wallet?: string } — same pattern. - Returns:
{ score: number } or { error }. - Prerequisite:
SCORE_BY_EMAIL_ENABLED must be set on the server. Higher fee.
Decision tree for common tasks
"Run a prediction for X"
CODEBLOCK0
"Link a bank account"
CODEBLOCK1
"Get my scores"
get_wallet_addresses
→ has aptos or evm? → get_agent_reputation_score + get_borrower_score
→ neither? → create wallets first, whitelist, then query
Error handling
| Error pattern | Meaning | What to do |
|---|
| INLINECODE82 | Wallet file missing | Call INLINECODE83 |
| INLINECODE84 |
Wallet file missing | Call
create_evm_wallet |
|
"already exist. Use force: true" | Wallet exists, not overwriting | Use existing wallet, or pass
force: true to add another |
|
"Payment verification failed" | Insufficient funds or wrong asset | Check balance; tell user to fund the wallet |
|
"No Aptos wallet configured" /
"No EVM wallet configured" | Paid tool needs wallet that doesn't exist | Create the missing wallet type |
|
"Unsupported chain" | Invalid chain name for
balance_evm | Use one of: base, baseSepolia, ethereum, polygon, arbitrum, optimism |
|
"timed out after 300s" | MCP call took too long | Retry once; the server may be under load |
|
"403" or
"not allowlisted" | Wallet not whitelisted | Tell user to whitelist address at https://arnstein.ch/flow.html |
Setup (for the human installing this skill)
- 1. Install:
npm install from repo root. Copy .env.example to .env. - Configure: Set wallet paths (
APTOS_WALLET_PATH, EVM_WALLET_PATH or EVM_PRIVATE_KEY). - Wallets: Create via tools (
create_aptos_wallet, create_evm_wallet) or CLI (node src/setup-aptos.js, node src/setup.js). Fund and whitelist all addresses at https://arnstein.ch/flow.html.
CLI commands (from repo root)
| Task | Command |
|---|
| Generate Aptos wallet | INLINECODE106 |
| Generate EVM wallet |
npm run setup |
| Show addresses for whitelist |
npm run addresses |
| Credit Aptos (devnet) |
npm run credit:aptos (set
APTOS_FAUCET_NETWORK=devnet) |
| EVM balance |
npm run balance -- <chain> |
| Transfer ETH/tokens |
npm run transfer -- <chain> <to> <amount> [tokenAddress] |
| Swap tokens (Odos) |
npm run swap -- <chain> <fromToken> <toToken> <amount> |
| Run skill demo |
npx cornerstone-agent "Run a 30-day prediction for AAPL" |
| Attest Aptos wallet |
npm run attest:aptos |
| Attest EVM wallet |
npm run attest:evm |
Source: FinTechTonic/autonomous-agent
CornerStone MCP x402 技能(面向智能体)
本技能为您(智能体)提供一套工具,用于:创建和管理 Aptos 及 EVM 钱包、查询余额,以及调用 x402 付费的 MCP 工具(股票预测、回测、银行账户关联、智能体/借款人评分)。支付是自动完成的——当付费工具返回 402 错误时,本技能会自动签名、验证、结算并重试。您只需调用工具,结果就会返回。
快速入门工作流程
首次使用时请按以下顺序操作,之后可直接跳转到所需工具:
- 1. 检查钱包 → 调用 getwalletaddresses(无需参数)。
- 如果为空 → 调用 createaptoswallet,然后调用 createevmwallet。
- 充值 → 调用 creditaptoswallet(Aptos 水龙头)和 fundevmwallet(EVM 水龙头说明)。
- 告知用户 在 https://arnstein.ch/flow.html 将返回的地址加入白名单。
- 检查余额 → 调用 balanceaptos(进行预测/回测必须有 USDC)和/或 balanceevm(关联银行账户必须有 ETH)。
- 使用付费工具 → runprediction、runbacktest、linkbankaccount 或评分工具。
重要提示: 如果地址尚未充值并加入白名单,付费工具将因钱包/白名单错误而失败。请务必先验证钱包和余额。
工具参考
钱包管理工具(本地)
getwalletaddresses
- - 参数: 无
- 返回: { aptos: [{ address, network }], evm: [{ address, network }] } — 可能为空数组。
- 使用时机: 在任何钱包或付费工具操作之前始终先调用。用于确定已存在的内容。
- 决策: 如果两个数组都为空 → 创建钱包。如果只有一个为空 → 创建缺失的钱包。如果两者都有条目 → 继续检查余额或使用付费工具。
createaptoswallet
- - 参数: { force?: boolean, network?: testnet | mainnet } — 默认值:force=false, network=testnet。
- 返回: { success, address, network, message } 或如果钱包已存在且 force=false,则返回 { success: false, message, addresses }。
- 使用时机: 当 getwalletaddresses 返回空的 aptos 数组,或用户请求创建新钱包时。
- 错误处理: 如果 success: false 且钱包已存在,要么使用现有钱包,要么使用 force: true 重试以添加另一个钱包。
createevmwallet
- - 参数: { force?: boolean, network?: testnet | mainnet } — 默认值:force=false, network=testnet。
- 返回: { success, address, network, message } 或 { success: false, message, addresses }。
- 模式与 createaptoswallet 相同。
creditaptoswallet
- - 参数: { amountoctas?: number } — 默认 100,000,000(= 1 APT)。
- 在 devnet 上返回: { success: true, address }(程序化水龙头已充值)。
- 在 testnet 上返回: { success: true, address, fauceturl }(仅说明;无程序化水龙头)。
- 前置条件: Aptos 钱包必须存在(先调用 createaptoswallet)。
- 注意: 充值的 APT 用于支付 gas 费;工具以 USDC 支付(约 6 美分)。用户可能需要单独获取测试网 USDC。
fundevmwallet
- - 参数: 无
- 返回: { success: true, address, fauceturl, message }(手动充值说明)。
- 前置条件: EVM 钱包必须存在(先调用 createevm_wallet)。
- 注意: 返回一个 Base Sepolia 水龙头 URL。用户必须手动充值;没有程序化水龙头。
余额工具(本地)
balance_aptos
- - 参数: 无
- 返回: { address, balances: { usdc, apt } } 或 { error }。
- 使用时机: 在调用 runprediction、runbacktest 或评分工具之前,确认是否有足够的 USDC。
balance_evm
- - 参数: { chain?: string } — 默认 base。支持:base、baseSepolia、ethereum、polygon、arbitrum、optimism。
- 返回: { address, chain, balance, symbol } 或 { error }。
- 使用时机: 在调用 linkbankaccount 之前,确认 Base Sepolia 上是否有足够的 ETH。
- 注意: 对于测试网工具,使用 chain: baseSepolia。
付费 MCP 工具(x402 — 自动处理支付)
所有付费工具都接受 Aptos 和 EVM 支付。本技能会选择最佳选项或遵循 PREFERREDPAYMENTORDER。您永远不会看到 402 错误——只需调用工具并获取结果或错误消息。
run_prediction
- - 参数: { symbol: string, horizon?: number } — symbol 是股票代码(例如 AAPL),horizon 是天数(默认 30)。
- 返回: 预测结果对象(预测数据、置信区间等)或 { error }。
- 费用: 约 6 美分 USDC(Aptos 或 EVM)。
- 前置条件: 已充值并加入白名单的 Aptos 或 EVM 钱包。
- 示例调用: run_prediction({ symbol: AAPL, horizon: 30 })
run_backtest
- - 参数: { symbol: string, startDate?: string, endDate?: string, strategy?: string } — 日期格式为 YYYY-MM-DD,strategy 默认为 chronos。
- 返回: 回测结果(收益率、回撤、夏普比率等)或 { error }。
- 费用: 约 6 美分 USDC。
- 示例调用: run_backtest({ symbol: TSLA, startDate: 2024-01-01, endDate: 2024-12-31, strategy: chronos })
linkbankaccount
- - 参数: 无
- 返回: { link_token } 或用于 Plaid 银行关联的账户 ID,或 { error }。
- 费用: 约 5 美分(EVM/Base)。
- 前置条件: 已充值并加入白名单的 EVM 钱包(测试网使用 Base Sepolia)。
getagentreputation_score
- - 参数: { agentaddress?: string, payerwallet?: string } — 两者均为可选;如果省略则使用配置的钱包。
- 返回: { reputationscore: number }(例如 100),如果未加入白名单则返回 403,或 { error }。
- 费用: 通过 x402 约 6 美分,或使用贷方积分免费(传递 payerwallet)。
getborrowerscore
- - 参数: { agentaddress?: string, payerwallet?: string } — 相同模式。
- 返回: { score: number }(基础值 100;关联银行后更高)或 { error }。
- 费用: 通过 x402 约 6 美分,或使用贷方积分免费。
getagentreputationscoreby_email
- - 参数: { email: string, payerwallet?: string } — 将电子邮件解析为已加入白名单的智能体。
- 返回: { reputationscore: number } 或 { error }。
- 前置条件: 服务器上必须设置 SCOREBYEMAIL_ENABLED。费用更高。
getborrowerscorebyemail
- - 参数: { email: string, payerwallet?: string } — 相同模式。
- 返回: { score: number } 或 { error }。
- 前置条件: 服务器上必须设置 SCOREBYEMAILENABLED