🪙 Pay any iUSD-paywalled API with one fetch — payment-skill × Initia × x402
An AI agent hit an Initia paywall, got
HTTP 402, the skill bridged USDC → iUSD via Skip:Go, signed a CosmosMsgSendoninitiation-2, paid 0.5 iUSD, walked off with the data — onefetchWithPayment(url)call, zero humans, ~30 seconds.SDK = https://www.npmjs.com/package/n-payment
The agentic-payment thesis on Cosmos rails — same x402 muscle memory, but on a stablecoin (iUSD) whose yield rebates to the ecosystem instead of the issuer. Here’s the playbook. 🎯
🎯 What “x402 on Initia” actually means
x402 on EVM is EIP-3009 transferWithAuthorization. Cosmos has no EIP-3009, so the agent signs a plain bank-module MsgSend instead. The skill calls this scheme cosmos-msgsend, and the dance is identical:
📡 Hit URL → server returns
HTTP 402with acosmos-msgsendchallenge✍️ Agent signs
MsgSend(amount=0.5 iUSD, denom=ibc/…, to=payTo)oninitiation-2⛓️ Tx broadcasts to Initia REST → block included → tx hash returned
🔁 Agent retries the URL with the tx-hash header → 200 OK + payload
The kicker: if the agent has no iUSD yet, the same tool bridges USDC from any EVM source via Skip:Go before signing. One pay_url call, no human approving anything mid-flow.
⚡ The Recipe (5 steps)
1️⃣ Install the skill + set 3 env vars
# One-shot — detects your AI host (Claude Code / Kiro / Cursor / Gemini / …)
npx -y github:phamdat721101/payment-skill
# Required for any signing path
export INITIA_MNEMONIC="word1 word2 … word12" # BIP-39, 12 or 24 words
export INITIA_IUSD_DENOM_TESTNET="ibc/<DENOM_HASH>" # iUSD denom on initiation-2🔑
INITIA_MNEMONICderives the agent’sinit1…bech32 address — never echoed, never written outside~/.n-payment/🪪
INITIA_IUSD_DENOM_TESTNETis mandatory — iUSD is an IBC denom, the hash differs testnet vs mainnet (useINITIA_IUSD_DENOM_MAINNETforinterwoven-1)📦 Optional peer deps (lazy-loaded on first signing call):
npm i @cosmjs/proto-signing @cosmjs/stargate @skip-go/client💧 Faucets:
uinitgas atfaucet.testnet.initia.xyz· Base Sepolia USDC atfaucet.circle.com
2️⃣ quote — corridor selector + Skip API preview (no signing, no tx)
n-payment-skill tools call iusd_bridge '{
"action": "quote",
"amount_iusd": "0.5",
"source_chain": "base-sepolia",
"dest_chain": "initia-testnet"
}'🧭 Returns the chosen
corridor(skip-apion testnet ·layerzero-ausd-oftorwormhole-ntton mainnet) + your current iUSD / USDC holdings💸 Pure read — no signer touched, no gas burned
🧪 Default route:
base-sepoliaUSDC →initia-testnetiUSD (testnet-first by design)
3️⃣ balance — confirm iUSD + native gas
n-payment-skill tools call iusd_bridge '{
"action": "balance",
"dest_chain": "initia-testnet"
}'
# {
# "address": "init1<INITIA_ADDR>",
# "iusd": "0.000000",
# "native_init": "0.250000",
# "denom": "ibc/<DENOM_HASH>"
# }🏷️ Reads iUSD (6 decimals) and
uinit(the gas token) in one call👀 Pass
addressto inspect any other Initia bech32 address (read-only, no mnemonic needed)
4️⃣ execute — bridge USDC → iUSD (dry-run first, then real)
# Dry-run: validate caps + corridor without sending tx
n-payment-skill tools call iusd_bridge '{
"action": "execute",
"amount_iusd": "0.5",
"source_chain": "base-sepolia",
"dest_chain": "initia-testnet",
"dry_run": true
}'
# Real: signs USDC source leg + Cosmos receive leg via Skip API
n-payment-skill tools call iusd_bridge '{
"action": "execute",
"amount_iusd": "0.5",
"source_chain": "base-sepolia",
"dest_chain": "initia-testnet"
}'
# {
# "corridor": "skip-api",
# "tx_hashes": ["<EVM_TX_HASH>", "<INITIA_TX_HASH>"],
# "iusd_landed": "0.500000",
# "duration_ms": 28411,
# "idempotency_key": "default-initia-testnet-0.5-1717…"
# }🛡️ Conservative caps:
IUSD_MAX_PER_TRANSFER=50/IUSD_MAX_PER_DAY=200(env-overridable)🔁
idempotency_keyauto-generated — replay safety baked in⏱️
timeout_msdefaults to 600s; bump on slow IBC days
5️⃣ pay_url — call any iUSD-paywalled endpoint (auto-bridge if short)
import { createPaymentClient } from 'n-payment';
const client = createPaymentClient({
chains: ['base-sepolia', 'initia-testnet'],
ows: { wallet: 'default', privateKey: process.env.BUYER_KEY },
initia: { network: 'testnet', mnemonic: process.env.INITIA_MNEMONIC! },
});
// One call — handles 402 cosmos-msgsend, auto-bridges USDC→iUSD if iUSD short
const res = await client.fetchWithPayment(
'https://your-iusd-paywall.example/agent-api/decisions?limit=5',
);
console.log(await res.json());🚦 If iUSD balance <
maxAmountRequired→ orchestrator quietly bridges, then signs theMsgSend🧾 Returns
{ status, body, chain }— same shape as every otherpay-style tool in the skill🤖 From an MCP host (Kiro / Claude Code / Cursor): just say “pay this iUSD URL” — the skill picks
iusd_bridgeautomatically
🧠 What’s under the hood
📦
IusdBridgeOrchestrator(n-payment v0.23) — picks the corridor, wires Skip API signers, enforces caps🧭
selectIusdCorridorranksskip-api/layerzero-ausd-oft/wormhole-nttagainst holdings + chain health🪪
InitiaClientsoft-loads@cosmjs/*, builds the bech32 signer from your mnemonic, broadcasts via Initia REST🛡️
guardMainnetruns before anyinterwoven-1send — flipn-payment-skill config set testnetMode falseto opt in
🚀 Why this matters
🤖 Agent-native stablecoin payments on Cosmos. Same
fetchWithPayment(url)mental model as EVM x402 — just a different signature scheme underneath.💰 iUSD’s yield rebates to the ecosystem. Every iUSD your agent holds is productive capital — the issuer doesn’t pocket the T-Bill yield.
🌉 Cross-VM out of the box. One client wires an EVM signer (viem) + a Cosmos signer (
@cosmjs/*) and lets Skip:Go orchestrate the legs.🔌 One tool, four actions.
quotefor pricing UX ·balancefor treasury reads ·executefor explicit bridging ·pay_urlfor the full 402 dance.
📚 Repos & links
🛠️ Skill:
payment-skill— install into any AI host with one command📦 SDK:
n-payment(v0.23+ foriusd_bridge)🟦 Initia docs:
docs.initia.xyz· networks: resources🪙 iUSD on DefiLlama:
defillama.com/stablecoin/initia-iusd🏦 Agora AUSD:
agora.finance· Wormhole + AUSD partnership🔗 LayerZero OFT:
layerzero.network· OFT docs🌉 Wormhole NTT:
wormhole.com/products/ntt· deep dive🚀 Skip:Go API:
docs.skip.build·/v2/fungible/route🌐 x402 spec:
docs.x402.org· Coinbase intro · GitHub🧱 Cosmos SDK
MsgSend: bank module reference ·@cosmjs/stargate(npm)💧 Faucets: Initia
faucet.testnet.initia.xyz· USDCfaucet.circle.com· Base Sepolia ETHalchemy.com/faucets/base-sepolia🔍 Explorers:
scan.testnet.initia.xyz·scan.initia.xyz


