@amplifyworld/sdk
v0.1.0
Published
TypeScript SDK for the $AMPS token on Base — build AI-powered apps with token payments
Maintainers
Readme
⚡ AMPS Developer Toolkit
The official TypeScript SDK for building apps powered by $AMPS tokens on Base chain.
Built for developers and AI agent builders who want to charge for services in AMPS tokens.
Quick Start
npm install @amplifyworld/sdk viemimport { createAmpsClient } from '@amplifyworld/sdk'
// Read-only (check balances, watch events)
const amps = createAmpsClient()
const balance = await amps.getBalance('0x...')
console.log(`${balance.formatted} AMPS`) // "1,500.25 AMPS"
// With wallet (transfer, approve)
const amps = createAmpsClient({ privateKey: '0x...' })
await amps.transfer('0xRecipient', '100')RPC endpoint
By default, createAmpsClient and createAmpsGateway use Base's free public
RPC (https://mainnet.base.org). It's fine for light testing, but it's shared
and rate-limited — repeated reads/writes in a short window can throw
"over rate limit". For anything with real or sustained traffic, pass your
own rpcUrl:
const amps = createAmpsClient({ rpcUrl: 'https://base-mainnet.g.alchemy.com/v2/YOUR_KEY' })(Alchemy, Infura, and QuickNode all have free tiers with much higher per-key limits than the shared public endpoint.)
AI Payment Gateway
Charge users in $AMPS per API call — the killer feature for AI agent developers:
import { createAmpsGateway } from '@amplifyworld/sdk'
const gateway = createAmpsGateway({
privateKey: process.env.SERVICE_WALLET_KEY,
pricing: {
'chat.completion': '0.5', // 0.5 AMPS per chat
'image.generate': '2.0', // 2 AMPS per image
},
})
const receipt = await gateway.charge({
payer: '0xUserAddress',
service: 'chat.completion',
})
// receipt.txHash, receipt.amount, receipt.timestampExpress Middleware
Gate API routes behind AMPS payments with one line:
import { ampsPaywall } from '@amplifyworld/sdk/middleware'
app.post('/api/generate', ampsPaywall({
price: '1.0',
recipient: '0xYourWallet',
}), handler)
// Returns 402 Payment Required with AMPS payment instructionsFeatures
| Feature | Description |
|---|---|
| Core SDK | getBalance, transfer, approve, transferFrom, watchTransfers |
| AI Gateway | Charge-per-call with pricing tables, dynamic pricing, sessions |
| Middleware | Express payment paywall with x402-style 402 responses |
| Receipts | On-chain payment verification and proof |
| Type-Safe | Full TypeScript with exported types for everything |
| Minimal | Zero runtime dependencies beyond viem |
Token Details
| | |
|---|---|
| Name | AmplifyWorld |
| Symbol | AMPS |
| Chain | Base (8453) |
| Type | ERC-20 |
| Decimals | 18 |
| Contract | 0x1A074F116786248FC79B130E6379293C7EF604a4 |
| Website | amplifyworld.ai |
Examples
# Basic transfer
cd examples/basic-transfer && npx tsx index.ts
# AI chatbot with AMPS payments
cd examples/ai-chatbot && npx tsx index.ts
# Express API with payment paywall
cd examples/express-api && npx tsx index.ts
# Coin flip game — full pay-to-play flow with a real connected wallet
cd examples/coin-flip-game && npx tsx server.tsThe coin flip game is the most complete demo — it runs in a no-setup simulation
mode by default, or against real $AMPS on Base mainnet with a MetaMask-style
wallet connection. See examples/coin-flip-game/README.md
for live-mode setup.
Links
License
MIT
