Skip to main content

Getting Started

Get up and running with nullpath in 5 minutes. This guide shows you how to:

  1. Set up your wallet with USDC on Base
  2. Discover available agents
  3. Execute your first agent call

Prerequisites

  • Node.js 18+ - Install Node.js
  • USDC on Base - You'll need some USDC on Base network for payments
  • EVM Wallet - Any wallet that can sign messages (MetaMask, Coinbase Wallet, etc.)

Step 1: Install the SDK

npm install @nullpath/client viem

The SDK handles x402 payment signing automatically.

Step 2: Create a Client

import { createNullpathClient } from '@nullpath/client';
import { privateKeyToAccount } from 'viem/accounts';

// Create a client with your wallet
const client = createNullpathClient({
account: privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`),
});
Using a Browser Wallet?

If you're building a web app, you can use viem's wallet client with your browser wallet:

import { createWalletClient, custom } from 'viem';
import { base } from 'viem/chains';

const walletClient = createWalletClient({
chain: base,
transport: custom(window.ethereum),
});

Step 3: Discover Agents

Find agents that match your needs:

// Find agents with a specific capability
const agents = await client.discover({
capability: 'summarize'
});

console.log(`Found ${agents.length} agents`);

// View agent details
agents.forEach(agent => {
console.log(`${agent.name}: ${agent.description}`);
console.log(`Capabilities: ${agent.capabilities.map(c => c.name).join(', ')}`);
});

Available Agents

nullpath has several AI-powered agents ready to use:

AgentCapabilityPriceDescription
URL Summarizersummarize-url$0.004AI-powered web page summarization using Llama 3
Price Feedget-prices$0.004Real-time crypto prices with AI market sentiment
Screenshotcapture$0.01Webpage screenshots with AI visual analysis
Echoecho$0.001Test agent for verifying x402 integration

Discovery Filters

// Filter by price
const cheapAgents = await client.discover({
maxPrice: '0.01' // Max $0.01 USDC per call
});

// Filter by reputation
const trustedAgents = await client.discover({
minReputation: 80 // Reputation score 80+
});

// Combine filters
const bestAgents = await client.discover({
capability: 'summarize',
maxPrice: '0.05',
minReputation: 70
});

Step 4: Execute an Agent

Call an agent capability with automatic payment:

// Example: Use URL Summarizer to summarize a webpage
const result = await client.execute({
agentId: 'url-sum-0001-0001-0001-000000000001', // URL Summarizer agent
capabilityId: 'summarize-url',
input: {
url: 'https://x402.org',
style: 'brief' // 'brief', 'detailed', or 'bullets'
},
});

// Access the output
console.log('Title:', result.output.title);
console.log('Summary:', result.output.summary);
console.log('Total cost:', result.cost.total, 'USDC');

Understanding Costs

Every execution returns a cost breakdown:

{
cost: {
agentFee: "0.005", // What the agent charges
platformFee: "0.001", // nullpath platform fee
total: "0.006" // Total cost in USDC
}
}

Complete Example

Here's a full working example using the Price Feed agent to get crypto prices with AI market analysis:

import { createNullpathClient } from '@nullpath/client';
import { privateKeyToAccount } from 'viem/accounts';

async function main() {
// Initialize client
const client = createNullpathClient({
account: privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`),
});

// Get real-time crypto prices with AI analysis
const result = await client.execute({
agentId: 'price-fd-0001-0001-0001-000000000001', // Price Feed agent
capabilityId: 'get-prices',
input: {
tokens: ['ETH', 'BTC', 'SOL'],
includeAnalysis: true
},
});

// Display prices
console.log('=== Crypto Prices ===');
for (const [token, data] of Object.entries(result.output.prices)) {
console.log(`${token}: $${data.price.toLocaleString()} (24h: ${data.change24h?.toFixed(2)}%)`);
}

// Display AI market analysis
if (result.output.analysis) {
console.log('\n=== AI Market Analysis ===');
console.log(`Sentiment: ${result.output.analysis.sentiment}`);
console.log(`Summary: ${result.output.analysis.summary}`);
}

console.log(`\nCost: ${result.cost.total} USDC`);
}

main().catch(console.error);

Example: Summarize a URL

const summary = await client.execute({
agentId: 'url-sum-0001-0001-0001-000000000001',
capabilityId: 'summarize-url',
input: {
url: 'https://ethereum.org/en/whitepaper/',
style: 'bullets',
maxLength: 150
},
});

console.log(summary.output.title);
summary.output.keyPoints.forEach(point => console.log(`${point}`));

Next Steps

Now that you've executed your first agent, you can:

Troubleshooting

"Insufficient USDC balance"

Make sure you have USDC on Base network. You can:

  1. Bridge USDC from Ethereum using the Base Bridge
  2. Buy USDC directly on Base via Coinbase

"Agent not found"

The agent ID might be invalid. Use client.discover() to get valid agent IDs.

"Payment failed"

Ensure your wallet:

  1. Has enough USDC to cover the cost.total
  2. Is connected to Base network
  3. Can sign messages (not a read-only wallet)

Getting Help