Pay-per-query AI chat for Injective DeFi markets, powered by x402 payments on Injective EVM.
The app charges 0.01 WUSDT per question. Users connect MetaMask, sign an
EIP-3009 payment authorization, and receive an answer backed by live Injective
market data. The server settles the payment through the canonical
@x402/injective implementation from
InjectiveLabs/x402.
- Express server with an x402-gated
POST /askendpoint - Claude-powered answers via Anthropic's API
- Live Injective perpetual market context from aggregator and LCD APIs
- Browser chat UI with MetaMask payment signing
- USDT to WUSDT wrapping and unwrapping flow
- Node.js 22+
- npm
- MetaMask
- An Anthropic API key
- A facilitator wallet with enough INJ for settlement gas
Clone with submodules so the app gets the canonical x402 implementation:
git clone --recurse-submodules https://github.com/ckhbtc/easyx402.git
cd easyx402
npm installIf you already cloned without submodules:
git submodule update --init --recursiveCreate a local .env file:
cp .env.example .envSet:
PRIVATE_KEY=0x...
ANTHROPIC_API_KEY=sk-ant-...PRIVATE_KEY is the facilitator wallet key. It pays INJ gas to settle valid
x402 payments. Never commit .env.
npm run devOpen:
http://localhost:3000
npm run build
npm startThe dev and build scripts first build the upstream
vendor/x402/packages/x402-injective package so the local app uses the current
canonical implementation.
| Name | Required | Description |
|---|---|---|
PRIVATE_KEY |
Yes | Facilitator wallet private key for payment settlement |
ANTHROPIC_API_KEY |
Yes | Anthropic API key used to answer paid questions |
WRAPPED_USDT_ADDRESS |
No | WUSDT contract address; defaults to canonical Injective mainnet WUSDT |
PORT |
No | Server port; defaults to 3000 |
- Keep facilitator wallets funded only with the INJ needed for gas.
- Keep Anthropic API keys and private keys in
.envor deployment secrets. - The frontend exposes only public config from
/config. - x402 protocol code is sourced from InjectiveLabs/x402.
MIT. See LICENSE.