Example Flows
Example Flows
Setup
Dependencies
npm install viemConfiguration
import { createWalletClient, http, keccak256, toHex } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
import { base } from 'viem/chains';
const GATEWAY_URL = 'https://x402.quickintel.io';
const PRIVATE_KEY = process.env.WALLET_PRIVATE_KEY;
const PROVIDER_NAME = 'my-trading-agent';
const account = privateKeyToAccount(PRIVATE_KEY);
const walletClient = createWalletClient({
account,
chain: base,
transport: http()
});Pricing Reminder
Call Type
Cost
Example 1: Price Check (Info Query)
Example 2: Buy Token
Example 3: Swap Tokens
Example 4: Bridge Assets
Example 5: Async Mode (Long Operations)
Example 6: Validate Prompt Before Sending
Example 7: Token Safety Check
Helper Functions
Sign x402 Payment ($0.20)
Submit Prompt with Payment
Sleep Helper
Error Handling
Full Working Example
Cost Summary
Operation
API Cost
Notes
Next Steps
Last updated