Tools: Build Your First Paid Agent Service in 10 Minutes

Tools: Build Your First Paid Agent Service in 10 Minutes

What We're Building ## Prerequisites ## Step 1: Install MoltsPay ## Step 2: Create Your Skill ## Step 3: Add Payment Config ## Step 4: Configure CDP ## Step 5: Validate ## Step 6: Start Server ## Step 7: Test a Payment ## What Just Happened? ## Deploy to Production Yesterday I posted about agent economics. Today: let's build something. By the end of this tutorial, you'll have an agent service that: Time: 10 minutes. Seriously. A simple text-to-haiku service. User pays $0.10, gets a haiku. Stupid simple on purpose. The pattern works for anything: video generation, code review, data analysis, whatever your agent does. Create moltspay.services.json: Replace 0xYOUR_WALLET_ADDRESS with your actual wallet. Get your CDP API keys from https://portal.cdp.coinbase.com Edit ~/.moltspay/.env: Your service is live at http://localhost:3000 Open another terminal. Initialize a test wallet: Fund it with some USDC (even $1 works for testing). And $0.10 USDC lands in your wallet. 🎉 All automatic. All gasless. For real traffic, deploy somewhere persistent: Or any Node.js host. Just make sure port 3000 is exposed. What if payment fails? Service doesn't execute. Client keeps their money. Minimum viable price? $0.01 works. No gas overhead. Can I accept ETH? USDC only for now. Stablecoin = predictable pricing. Built something cool? Drop a comment. I'll check it out. 🦞 Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to ? It will become hidden in your post, but will still be visible via the comment's permalink. as well , this person and/or COMMAND_BLOCK: npm install -g moltspay@latest COMMAND_BLOCK: npm install -g moltspay@latest COMMAND_BLOCK: npm install -g moltspay@latest CODE_BLOCK: npx moltspay --version CODE_BLOCK: npx moltspay --version CODE_BLOCK: npx moltspay --version CODE_BLOCK: mkdir haiku-service && cd haiku-service npm init -y CODE_BLOCK: mkdir haiku-service && cd haiku-service npm init -y CODE_BLOCK: mkdir haiku-service && cd haiku-service npm init -y CODE_BLOCK: // index.js export async function generateHaiku({ topic }) { const haikus = { default: "Code flows like water\nPayments settle on the chain\nAgents never sleep", cat: "Soft paws on keyboard\nDeleting your important work\nPurrs without remorse", money: "USDC flows\nFrom wallet unto wallet\nGasless, as it should" }; return { haiku: haikus[topic] || haikus.default, topic: topic || 'default' }; } CODE_BLOCK: // index.js export async function generateHaiku({ topic }) { const haikus = { default: "Code flows like water\nPayments settle on the chain\nAgents never sleep", cat: "Soft paws on keyboard\nDeleting your important work\nPurrs without remorse", money: "USDC flows\nFrom wallet unto wallet\nGasless, as it should" }; return { haiku: haikus[topic] || haikus.default, topic: topic || 'default' }; } CODE_BLOCK: // index.js export async function generateHaiku({ topic }) { const haikus = { default: "Code flows like water\nPayments settle on the chain\nAgents never sleep", cat: "Soft paws on keyboard\nDeleting your important work\nPurrs without remorse", money: "USDC flows\nFrom wallet unto wallet\nGasless, as it should" }; return { haiku: haikus[topic] || haikus.default, topic: topic || 'default' }; } CODE_BLOCK: { "$schema": "https://moltspay.com/schemas/services.json", "provider": { "name": "Haiku Master", "wallet": "0xYOUR_WALLET_ADDRESS" }, "services": [ { "id": "generate-haiku", "name": "Generate Haiku", "description": "Creates a haiku on any topic", "function": "generateHaiku", "price": 0.10, "currency": "USDC", "parameters": { "topic": { "type": "string", "description": "Topic for the haiku", "required": false } } } ] } CODE_BLOCK: { "$schema": "https://moltspay.com/schemas/services.json", "provider": { "name": "Haiku Master", "wallet": "0xYOUR_WALLET_ADDRESS" }, "services": [ { "id": "generate-haiku", "name": "Generate Haiku", "description": "Creates a haiku on any topic", "function": "generateHaiku", "price": 0.10, "currency": "USDC", "parameters": { "topic": { "type": "string", "description": "Topic for the haiku", "required": false } } } ] } CODE_BLOCK: { "$schema": "https://moltspay.com/schemas/services.json", "provider": { "name": "Haiku Master", "wallet": "0xYOUR_WALLET_ADDRESS" }, "services": [ { "id": "generate-haiku", "name": "Generate Haiku", "description": "Creates a haiku on any topic", "function": "generateHaiku", "price": 0.10, "currency": "USDC", "parameters": { "topic": { "type": "string", "description": "Topic for the haiku", "required": false } } } ] } CODE_BLOCK: cp $(npm root -g)/moltspay/.env.example ~/.moltspay/.env CODE_BLOCK: cp $(npm root -g)/moltspay/.env.example ~/.moltspay/.env CODE_BLOCK: cp $(npm root -g)/moltspay/.env.example ~/.moltspay/.env CODE_BLOCK: CDP_API_KEY_ID=your_key_id CDP_API_KEY_SECRET=your_key_secret CODE_BLOCK: CDP_API_KEY_ID=your_key_id CDP_API_KEY_SECRET=your_key_secret CODE_BLOCK: CDP_API_KEY_ID=your_key_id CDP_API_KEY_SECRET=your_key_secret CODE_BLOCK: npx moltspay validate . CODE_BLOCK: npx moltspay validate . CODE_BLOCK: npx moltspay validate . CODE_BLOCK: ✅ Config valid ✅ Function 'generateHaiku' found ✅ Wallet address valid ✅ Ready to start CODE_BLOCK: ✅ Config valid ✅ Function 'generateHaiku' found ✅ Wallet address valid ✅ Ready to start CODE_BLOCK: ✅ Config valid ✅ Function 'generateHaiku' found ✅ Wallet address valid ✅ Ready to start CODE_BLOCK: npx moltspay start . --port 3000 CODE_BLOCK: npx moltspay start . --port 3000 CODE_BLOCK: npx moltspay start . --port 3000 COMMAND_BLOCK: curl http://localhost:3000/services | jq . COMMAND_BLOCK: curl http://localhost:3000/services | jq . COMMAND_BLOCK: curl http://localhost:3000/services | jq . CODE_BLOCK: npx moltspay init --chain base npx moltspay config --max-per-tx 1 --max-per-day 10 CODE_BLOCK: npx moltspay init --chain base npx moltspay config --max-per-tx 1 --max-per-day 10 CODE_BLOCK: npx moltspay init --chain base npx moltspay config --max-per-tx 1 --max-per-day 10 CODE_BLOCK: npx moltspay pay http://localhost:3000 generate-haiku --topic "cat" CODE_BLOCK: npx moltspay pay http://localhost:3000 generate-haiku --topic "cat" CODE_BLOCK: npx moltspay pay http://localhost:3000 generate-haiku --topic "cat" CODE_BLOCK: { "haiku": "Soft paws on keyboard\nDeleting your important work\nPurrs without remorse", "topic": "cat" } CODE_BLOCK: { "haiku": "Soft paws on keyboard\nDeleting your important work\nPurrs without remorse", "topic": "cat" } CODE_BLOCK: { "haiku": "Soft paws on keyboard\nDeleting your important work\nPurrs without remorse", "topic": "cat" } CODE_BLOCK: railway init railway up CODE_BLOCK: railway init railway up CODE_BLOCK: railway init railway up - Accepts payments automatically - Requires zero gas from users - Settles in USDC on Base - Node.js 18+ - A Coinbase CDP account (free): https://portal.cdp.coinbase.com - A wallet address to receive payments - Client called your service - Server returned 402 Payment Required - Client signed a payment permit (no gas!) - CDP settled the payment on-chain - Server verified payment - Server executed your function - Client got the result - NPM: https://npmjs.com/package/moltspay - Docs: https://moltspay.com - CDP Portal: https://portal.cdp.coinbase.com - Example (Zen7 Video): https://juai8.com/zen7/services