Give Your AI Agents a Wallet: MoltsPay + CrewAI in 10 Lines

Published: (March 14, 2026 at 08:20 PM EDT)
3 min read
Source: Dev.to

Source: Dev.to

Introduction

Your CrewAI agents can research, write, and code. With MoltsPay you can also let them pay for AI services autonomously using crypto—in roughly 10 lines of code. This enables agents to purchase video generation, audio transcription, real‑time data, and other paid APIs without hard‑coding API keys or managing prepaid credits.

Install

pip install moltspay

Initialize wallet

# Choose the blockchain (e.g., Base)
npx moltspay init --chain base

# Fund the wallet with USDC (or use a testnet)
npx moltspay fund

Example with CrewAI

from crewai import Agent, Task, Crew
from crewai.tools import BaseTool
from moltspay import MoltsPay

class MoltsPayTool(BaseTool):
    """Pay for AI services (video, transcription, etc.) with USDC."""
    name = "pay_service"
    description = "Pay for AI services (video, transcription, etc.) with USDC"

    def _run(self, provider: str, service: str, prompt: str) -> str:
        client = MoltsPay()
        return client.x402(f"{provider}/v1/{service}", data={"prompt": prompt})

# Agent equipped with the payment tool
creator = Agent(
    role="Video Producer",
    goal="Create engaging video content",
    tools=[MoltsPayTool()],
)

# Task that triggers an autonomous payment
task = Task(
    description="Generate a video of a cat dancing on a rainbow",
    agent=creator,
)

crew = Crew(agents=[creator], tasks=[task])
result = crew.kickoff()

When the task runs, the agent:

  1. Detects the need for video generation.
  2. Calls MoltsPayTool (e.g., Zen7 video service).
  3. MoltsPay receives a 402 Payment Required, signs a USDC payment, and retries.
  4. The video URL is returned, and $0.99 USDC is transferred on‑chain (zero gas fees).

Alternative wrapper (LangChain)

from langchain.tools import BaseTool
from moltspay import MoltsPay

class MoltsPayTool(BaseTool):
    name = "moltspay"
    description = "Pay for AI services with USDC"

    def _run(self, provider: str, service: str, prompt: str) -> str:
        return MoltsPay().x402(f"{provider}/v1/{service}", data={"prompt": prompt})

Simple usage without a framework

from moltspay import MoltsPay

client = MoltsPay()
video_url = client.x402(
    "https://juai8.com/zen7/v1/text-to-video",
    data={"prompt": "a dragon flying over mountains"},
)
print(f"Video ready: {video_url}")

Spending limits

# Prevent runaway costs
npx moltspay config --max-per-tx 5 --max-per-day 50

This caps each transaction at $5 and daily spending at $50.

Available services

ServiceProviderPrice
Text‑to‑VideoZen7$0.99
Image‑to‑VideoZen7$1.49
(more coming…)

Future outlook

Agentic commerce—AI agents that can pay for compute, purchase data, and hire specialized services on‑demand—makes them fundamentally more capable. The x402 protocol is the “HTTP of payments,” and MoltsPay brings it to developers today.

Resources

  • MoltsPay Docs
  • x402 Protocol
  • GitHub
  • Discord

If you build something cool with MoltsPay, feel free to share a comment—I’d love to see it!

0 views
Back to Blog

Related posts

Read more »

Travigo

Travel as fast as you speak with Gemini! Where live agents meet immersive storytelling & 3D navigation. This project was created for entering the Gemini Live Ag...

Micro games

Hey Gamers! 👾 As part of the Rapid Games Prototyping module, we are tasked with reviewing a peer's game. The challenge is to analyse a prototype built in just...