Open app

Quickstart: pay from an agent

Create an agent, give it its key, and make its first paid call.

You need a Solana wallet in your browser with some SOL and USDC, and Node 22 where the agent runs.

  1. Make a private wallet and deposit

    Open /app, connect your wallet, press Make a private wallet and sign. Then press Deposit and move some USDC into your private balance.

  2. Create the agent

    Go to /app/agents, press New agent, name it, pick USDC and set an allowance. Sign the two transactions. Copy AYO_AGENT_KEY from the done screen: it's shown once.

  3. Install the SDK

    Install
    npm install @ayo/sdk
  4. Set the environment

    .env
    AYO_AGENT_KEY=<the key from the done screen>
    AYO_PROGRAM_ID=<Ayo program ID>
    AYO_RPC_URL=<Solana RPC URL>
    AYO_API_URL=<Ayo API URL>

    The SDK reference lists every variable.

  5. Make a paid call

    agent.ts
    import { agent } from '@ayo/sdk'
    
    const payments = agent(process.env.AYO_AGENT_KEY!)
    
    const res = await payments.fetch('https://search.example/v1/search?q=solana')
    console.log(res.status, await res.json())
    
    await payments.shutdown()

    Use any listed service's endpoint from /app/services. The first call gets the service's hello, opens a tab and is repeated with a voucher. shutdown() settles the tab before the process exits.

  6. Watch it

    Open the agent's page in the app. The call is in its live feed with its amount, the tab shows open, then settled after shutdown(). Switch to the chain view to see what anyone else sees: a tab opened and closed between two addresses, with no amount.

Next