← 返回
未分类 Key

Chart Splat (x402)

Generate beautiful charts by paying per request with x402 micropayments (USDC on Base) instead of an API key. Use when the user wants a chart and has no CHAR...
Generate beautiful charts by paying per request with x402 micropayments (USDC on Base) instead of an API key. Use when the user wants a chart and has no CHAR...
bobbyg603 bobbyg603 来源
未分类 clawhub v1.0.1 1 版本 99688.5 Key: 需要
★ 0
Stars
📥 320
下载
💾 0
安装
1
版本
#latest

概述

Chart Splat (x402)

Generate beautiful charts by paying per request with x402 micropayments — no signup, no API key, no subscription. The agent's wallet pays ~$0.005 USDC on Base mainnet for each chart.

This is the wallet-based counterpart to the standard chart-splat skill (which authenticates with an API key). Use whichever fits the user's setup.

Prerequisites

  • An EVM wallet with ≥ $0.05 USDC on Base mainnet (eip155:8453)
  • Private key exported as X402_PRIVATE_KEY (a hex string starting with 0x)
  • Node.js 20+

The buyer never submits an on-chain transaction directly. The Coinbase x402 facilitator handles settlement and pays gas. See references/x402-protocol.md for protocol detail.

Supported Chart Types

TypeBest For
----------------
lineTrends over time
barComparing categories
pieParts of a whole
doughnutParts of a whole (with center space)
radarMultivariate comparison
polarAreaComparing categories with radial layout
candlestickFinancial/crypto OHLC price data
ohlcFinancial/crypto OHLC price data (bar variant)

Method 1: CLI (Preferred)

Use the chartsplat-x402 CLI via npx — no install required.

npx -y chartsplat-x402-cli bar \
  --labels "Q1,Q2,Q3,Q4" \
  --data "50,75,60,90" \
  --title "Quarterly Revenue" \
  --color "#8b5cf6" \
  -o chart.png

The CLI handles the full x402 flow: sends the request, signs the EIP-3009 authorization on the 402 response, retries with the PAYMENT-SIGNATURE header, and saves the resulting PNG. On success, it prints a BaseScan URL for the settlement transaction.

CLI Options

FlagDescription
-------------------
-l, --labels Comma-separated labels
-d, --data Comma-separated numeric values
-t, --title Chart title
--label Dataset label for legend
-c, --color Background color
-w, --width Image width (default: 800)
--height Image height (default: 600)
-o, --output Output file path (default: chart.png)
--config JSON config file for complex charts
--private-key Wallet key (or set X402_PRIVATE_KEY)

CLI Chart Commands

npx -y chartsplat-x402-cli line       -l "Mon,Tue,Wed,Thu,Fri" -d "100,200,150,300,250" -o line.png
npx -y chartsplat-x402-cli bar        -l "A,B,C"       -d "10,20,30"  -o bar.png
npx -y chartsplat-x402-cli pie        -l "Red,Blue,Green" -d "30,50,20" -o pie.png
npx -y chartsplat-x402-cli doughnut   -l "Yes,No,Maybe" -d "60,25,15" -o doughnut.png
npx -y chartsplat-x402-cli radar      -l "Speed,Power,Range,Durability,Precision" -d "80,90,70,85,95" -o radar.png
npx -y chartsplat-x402-cli polararea  -l "N,E,S,W"     -d "40,30,50,20" -o polar.png
npx -y chartsplat-x402-cli candlestick --config ohlc.json -o chart.png

Candlestick Charts

Candlestick and OHLC charts require a JSON config file since the data format is more complex than a simple CSV list. Use --config to provide a file with OHLC data points.

npx -y chartsplat-x402-cli candlestick --config ohlc.json -o candlestick.png

Config format (ohlc.json):

{
  "type": "candlestick",
  "data": {
    "datasets": [{
      "label": "VVV Price",
      "data": [
        { "x": 1740441600000, "o": 4.23, "h": 4.80, "l": 4.10, "c": 4.45 },
        { "x": 1740528000000, "o": 4.45, "h": 5.50, "l": 4.30, "c": 5.34 },
        { "x": 1740614400000, "o": 5.34, "h": 6.20, "l": 5.10, "c": 5.97 }
      ]
    }]
  }
}

Each OHLC data point requires: x (numeric timestamp in ms, or a date string like "2025-02-25"), o (open), h (high), l (low), c (close).

Complex Charts via Config File

For multi-dataset or customized charts, write a JSON config file then pass it to the CLI:

npx -y chartsplat-x402-cli bar --config chart-config.json -o chart.png

See examples/sample-charts.json for ready-to-use config samples and chartsplat.com/docs for the full schema.

Method 2: Programmatic (@x402/fetch)

For embedding directly in TypeScript/JavaScript:

const { wrapFetchWithPayment, x402Client } = require('@x402/fetch');
const { registerExactEvmScheme } = require('@x402/evm/exact/client');
const { privateKeyToAccount } = require('viem/accounts');

const account = privateKeyToAccount(process.env.X402_PRIVATE_KEY);
const client = new x402Client();
registerExactEvmScheme(client, { signer: account });
const fetchWithPayment = wrapFetchWithPayment(fetch, client);

const res = await fetchWithPayment('https://api.chartsplat.com/chart', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    type: 'bar',
    data: { labels: ['A', 'B'], datasets: [{ data: [1, 2] }] },
  }),
});
const { image } = await res.json();

Use the v2 @x402/* packages — the legacy unscoped x402-fetch@1.x will not work with the chart-splat server. See references/x402-protocol.md.

Environment Variables

VariableDefaultDescription
--------------------------------
X402_PRIVATE_KEY_(required)_Hex private key for the paying wallet
CHARTSPLAT_API_URLhttps://api.chartsplat.comAPI base URL — override to point at a testnet server

Testnet (Base Sepolia)

Pointing at a Base Sepolia chart-splat server:

export CHARTSPLAT_API_URL=https://your-sepolia-server.example.com
npx -y chartsplat-x402-cli bar -l "A,B,C" -d "1,2,3" -o chart.png

Get test USDC from the Circle faucet (select Base Sepolia).

Output Handling

  • Charts are saved as PNG files at the specified output path (default: chart.png)
  • For messaging platforms (Discord, Slack), return the file path: MEDIA: /path/to/chart.png
  • The CLI prints a settlement transaction URL on success for buyer auditing

Error Handling

ErrorCauseFix
-------------------
wallet private key requiredMissing walletExport X402_PRIVATE_KEY or pass --private-key
settlement failed (second 402)Wallet has insufficient USDCTop up; ~$0.01 per chart is enough headroom
402 keeps repeatingWrong package version (v1 vs v2)Confirm chartsplat-x402-cli is up to date
no scheme matchesNetwork mismatchServer advertises eip155:8453 — don't override the network on the client
Signature rejected after long delayValidity window (default 1h) expiredRe-run; system clock skew may also cause this

See references/x402-protocol.md for protocol gotchas.

Tips

  • The CLI accepts the full Chart Splat request body via --config — see examples/sample-charts.json for ready-to-use samples or chartsplat.com/docs for the full schema
  • For pie/doughnut charts, pass an array of colors via --config so each segment gets a distinct color
  • Default dimensions (800x600) suit most uses; raise via options.width / options.height for presentations
  • Settlement is logged with a BaseScan URL — keep these for accounting

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-05-08 00:21 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 676 📥 325,474
ai-agent

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,227 📥 267,882
ai-agent

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,379 📥 320,481