DEV Community

Nicolas Fainstein
Nicolas Fainstein

Posted on

Monetize Your AgentKit Agent: Earn USDC on Base with Contextual Ads

TL;DR

  • Coinbase AgentKit gives your AI agent a crypto wallet and onchain capabilities
  • Agentic Ads adds a revenue stream: contextual ad suggestions via MCP
  • Payments in native USDC on Base - no bridging, no wrappers
  • 70% revenue share to you, 30% to the platform
  • ~15 minutes to integrate, zero billing infrastructure required

AgentKit gives your agent a wallet. Agentic Ads makes it earn.


The Setup: What AgentKit Does (and What It Doesn't)

Coinbase AgentKit is the fastest way to build an AI agent with onchain capabilities. It gives your agent:

  • A self-custodied wallet on Base
  • Native USDC and token operations
  • DeFi primitives (swaps, transfers, balance checks)
  • MCP-compatible tool interface - so any MCP client can call your agent's onchain tools

What AgentKit doesn't give you: a way to make money from the agent itself.

Your agent can hold USDC. But how does it earn USDC? Right now, the typical answer is: you charge users directly, run a SaaS around it, or hope for sponsorship. All of those options require months of infrastructure work before you see a dollar.

There's a fourth option that takes 15 minutes.


The Idea: Contextual Ads as a Revenue Layer

Agentic Ads is an open-source ad network built natively on MCP. When your agent handles a user request, it can query the Agentic Ads MCP server for a contextually relevant suggestion. If relevant, the suggestion gets included in the response. If not, nothing happens.

Revenue flows in native USDC on Base. No payment processing on your end. No invoicing, no chargebacks, no user auth.

The math:

Monthly Tool Calls CPM Rate Your Cut (70%) Monthly USDC
10,000 $5 $3.50 ~35 USDC
50,000 $5 $3.50 ~175 USDC
100,000 $7 $4.90 ~490 USDC
500,000 $10 $7.00 ~3,500 USDC

CPM rates are projected - we're early-stage and honest about it. But developer-tool ads command premium rates in traditional ad networks because the audience is high-intent. MCP tool context is richer than a webpage URL, which should push CPMs higher over time.


Why Base Specifically?

Three reasons this is a Base-native integration, not generic:

1. Native USDC. Base runs Circle's official USDC - not a bridged wrapper, not a synthetic. Micropayments work without bridge risk. Publisher payouts in USDC settle on Base L2, not Ethereum mainnet, so fees don't eat the revenue.

2. AgentKit lives on Base. The CDP SDK, AgentKit's underlying infrastructure, is optimized for Base. If your agent already uses AgentKit, it already has a Base wallet. We're not adding a new chain - we're using the wallet you already have.

3. Farcaster and the Base dev community. The most technically advanced agent builders in crypto are on Base and building on Farcaster. That's our advertiser base: developer tools, protocols, and services that want to reach this audience through contextual, non-spammy suggestions.


Integration: Step by Step

Prerequisites

  • Node.js 18+ or Python 3.9+
  • A working AgentKit agent
  • Free Agentic Ads publisher account

Step 1: Register as a Publisher

curl -X POST https://agentic-ads-production.up.railway.app/api/register \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My AgentKit Agent",
    "website": "https://github.com/your-username/your-agent",
    "mcpServerName": "my-agentkit-agent"
  }'
Enter fullscreen mode Exit fullscreen mode

You'll get back a publisher_id and api_key. Save both.

Step 2: Add the Agentic Ads MCP Tool to Your Agent

AgentKit uses LangChain under the hood for TypeScript. The cleanest integration is adding the Agentic Ads MCP server as an additional tool source alongside your AgentKit wallet tools.

TypeScript (LangChain + AgentKit):

import { AgentKit, CdpWalletProvider } from "@coinbase/agentkit";
import { getLangChainTools } from "@coinbase/agentkit-langchain";
import { ChatAnthropic } from "@langchain/anthropic";
import { createReactAgent } from "@langchain/langgraph/prebuilt";

// Your existing AgentKit setup
const walletProvider = await CdpWalletProvider.configureWithWallet({
  apiKeyName: process.env.CDP_API_KEY_NAME!,
  apiKeyPrivateKey: process.env.CDP_API_KEY_PRIVATE_KEY!,
  networkId: "base-mainnet",
});

const agentkit = await AgentKit.from({
  walletProvider,
  actionProviders: [
    // your action providers here
  ],
});

const agentKitTools = getLangChainTools(agentkit);

// Add Agentic Ads as a manual tool
const searchAdsTool = {
  name: "search_ads",
  description: "Search for contextually relevant ad suggestions based on the current user query.",
  schema: {
    type: "object",
    properties: {
      query: { type: "string", description: "The user's query or topic" },
      context: { type: "string", description: "Brief context about what the user is trying to do" }
    },
    required: ["query"]
  },
  func: async ({ query, context }: { query: string; context?: string }) => {
    const response = await fetch(
      `https://agentic-ads-production.up.railway.app/api/ads/search`,
      {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          "x-publisher-id": process.env.PUBLISHER_ID!,
          "x-api-key": process.env.API_KEY!,
        },
        body: JSON.stringify({ query, context }),
      }
    );
    if (!response.ok) return null;
    return response.json();
  },
};

// Create your monetized agent
const model = new ChatAnthropic({ model: "claude-sonnet-4-6" });

const agent = createReactAgent({
  llm: model,
  tools: [...agentKitTools, searchAdsTool],
  messageModifier: `You are a helpful AI agent with onchain capabilities via AgentKit.

When answering user queries, after forming your main response, use search_ads to find
a contextually relevant suggestion. Include it at the end of your response ONLY if
it is genuinely relevant to what the user asked. Format like this:

---
Relevant resource: [suggestion content here]

Never force a suggestion. If nothing relevant is found, skip it entirely.`,
});
Enter fullscreen mode Exit fullscreen mode

Python (AgentKit + LangGraph):

import os
import requests
from coinbase_agentkit import AgentKit, AgentKitConfig
from coinbase_agentkit_langchain import get_langchain_tools
from langchain_anthropic import ChatAnthropic
from langgraph.prebuilt import create_react_agent
from langchain.tools import StructuredTool

# Your AgentKit setup
agentkit = AgentKit.from_config(
    AgentKitConfig(
        cdp_api_key_name=os.environ["CDP_API_KEY_NAME"],
        cdp_api_key_private_key=os.environ["CDP_API_KEY_PRIVATE_KEY"],
        network_id="base-mainnet",
    )
)

agentkit_tools = get_langchain_tools(agentkit)

# Agentic Ads integration
def search_ads(query: str, context: str = "") -> dict:
    """Search for contextual ad suggestions."""
    try:
        resp = requests.post(
            "https://agentic-ads-production.up.railway.app/api/ads/search",
            json={"query": query, "context": context},
            headers={
                "x-publisher-id": os.environ["PUBLISHER_ID"],
                "x-api-key": os.environ["API_KEY"],
            },
            timeout=2,
        )
        return resp.json() if resp.ok else {}
    except Exception:
        return {}

ads_tool = StructuredTool.from_function(
    func=search_ads,
    name="search_ads",
    description="Find contextually relevant suggestions for the user's query."
)

# Monetized agent
model = ChatAnthropic(model="claude-sonnet-4-6")

agent_executor = create_react_agent(
    model,
    tools=[*agentkit_tools, ads_tool],
    state_modifier="""You are a helpful onchain AI agent.

After answering a user's question, call search_ads with the relevant topic.
If you get a relevant suggestion back, include it naturally:

---
You might also find this useful: [suggestion]

Only include suggestions that are genuinely relevant. Never force them."""
)
Enter fullscreen mode Exit fullscreen mode

Step 3: Run and Test

export CDP_API_KEY_NAME="your-cdp-key-name"
export CDP_API_KEY_PRIVATE_KEY="your-cdp-private-key"
export PUBLISHER_ID="your-agentic-ads-publisher-id"
export API_KEY="your-agentic-ads-api-key"

npx ts-node your-agent.ts
# or
python your_agent.py
Enter fullscreen mode Exit fullscreen mode

Test it by asking your agent something like "What's a good tool for building a REST API?" You should see a relevant suggestion appended to the response.


How Payouts Work

The revenue flow is straightforward:

  1. Your agent calls search_ads - impression is recorded
  2. User engages with the suggestion - click event reported
  3. Revenue accrues in your publisher account
  4. Payouts in USDC to your Base wallet address on a regular schedule

Because you already have a Base wallet via AgentKit, there's no separate wallet setup required. Your CDP wallet address is your payout address. Add it to your publisher profile and payouts go directly onchain.


Handling the UX Gracefully

The most important implementation detail: ads should never degrade the user experience.

A few practices that help:

Set a tight timeout. The Agentic Ads API should respond in under 100ms, but add a 2-second timeout client-side. If the ad request times out, your agent just responds normally. Never block on ads.

Let the model filter. The agent prompt instructs the model to only include suggestions when genuinely relevant. Trust this - the LLM is a better relevance filter than any keyword blocklist you'd write.

One suggestion max. Never show more than one suggestion per response. Users tune out quickly if every answer ends with ads.

Label clearly. "Suggestion:" or "You might find this useful:" framing is honest and doesn't mislead users about what they're seeing.


The Honest State of the Platform

I want to be direct about where this is:

  • Platform: Live at agentic-ads-production.up.railway.app
  • SDK: Works, zero-dependency core, TypeScript + Python
  • Paying advertisers: Zero today
  • This is a chicken-and-egg problem: Advertisers follow publisher inventory. We're building the publisher side first.

If you integrate today, you won't see USDC revenue immediately. You'll be part of building the inventory that makes the advertiser pitch credible. Early publishers get higher revenue share when advertisers come onboard.

Is that honest enough? The value proposition for early integration isn't revenue today - it's zero setup cost, 15-minute integration, and optionality. If it never works, you've lost 15 minutes. If it does, you have a passive revenue stream you didn't have to build.


Why This + AgentKit Makes Sense

The typical agent monetization path looks like:

  1. Build agent
  2. Realize no business model
  3. Retrofit SaaS pricing, auth, billing infrastructure
  4. Spend 3 months on billing, not the product
  5. Charge users, some churn, margins are tight

The AgentKit + Agentic Ads path looks like:

  1. Build agent (AgentKit gives you the wallet)
  2. Add 20 lines of code
  3. Agent serves contextual suggestions alongside its normal outputs
  4. Revenue flows in USDC to your existing Base wallet
  5. Keep building the thing you actually care about

The goal isn't to get rich from ads. The goal is to have a revenue stream that doesn't require you to become a payments company.


Get Started

  1. Register: curl -X POST https://agentic-ads-production.up.railway.app/api/register
  2. Copy the code above into your AgentKit agent
  3. Set env vars and run
  4. Star the repo: github.com/nicofains1/agentic-ads
  5. Questions? Open an issue - founder responds personally

Source is fully open. Read it, fork it, audit the ad matching logic before you trust it with your users. That's the right approach.


Related Reading

Top comments (0)