# ai agents

## Vision

BaseGold powers the world's first X402-enabled AI agent economy, where autonomous agents can hold, transact, and earn gold-backed rewards without human intervention.

***

## What Are AI Agents?

AI agents are autonomous software programs that can:

* Execute tasks without human oversight
* Manage treasuries and budgets
* Pay for services programmatically
* Interact with smart contracts
* Operate 24/7 without breaks

***

## Why AI Agents Need BGOLD

| Challenge                     | How BGOLD Solves It                         |
| ----------------------------- | ------------------------------------------- |
| Value stability for budgeting | VNXAU rewards provide gold-backed stability |
| Microtransaction costs        | Base L2 offers sub-cent transaction fees    |
| Real-time operations          | Sub-second finality on Base                 |
| Passive income generation     | Automatic VNXAU reflection rewards          |
| Programmable payments         | Full smart contract compatibility           |

***

## AI Agent Use Cases

{% stepper %}
{% step %}

### Autonomous Treasury Management

AI Agent holds BGOLD → Earns VNXAU → Sells for operations → Compounds BGOLD

* Agents can autonomously maintain treasury allocations.
* Passive VNXAU reflections increase reserves over time.
* Agents can sell portions of BGOLD to fund operational costs and reinvest or compound.
  {% endstep %}

{% step %}

### Service-to-Service Payments

AI agents pay other AI agents in BGOLD for:

* Data access and APIs
* Compute resources
* Storage services
* Model inference
* Programmable payments enable seamless service-level transactions between agents.
* Low-fee Base L2 payments make frequent microtransactions feasible.
  {% endstep %}

{% step %}

### AI Payroll

Organizations pay AI agents in BGOLD, which generates gold rewards as compensation.

* BGOLD serves as a stable, interest-bearing compensation mechanism for deployed agents.
* Rewards (VNXAU) accumulate automatically, aligning incentives.
  {% endstep %}

{% step %}

### Cross-Agent Commerce

Decentralized marketplace where AI agents trade services using BGOLD as the payment standard.

* BGOLD acts as a trusted settlement currency across agent ecosystems.
* Enables composable, autonomous commerce between agents and services.
  {% endstep %}
  {% endstepper %}

***

## Agent Integration Flow

{% @mermaid/diagram content="sequenceDiagram
participant Agent as AI Agent
participant API as Service API
participant X402 as X402 Protocol
participant Backend as BaseGold Backend
participant Contract as BGOLD Contract

```
Agent->>API: Request service/data
API-->>Agent: 402 Payment Required
Note over Agent,API: Headers: X-Payment-Amount, X-Payment-Address

Agent->>Agent: Parse payment requirements
Agent->>X402: Initiate autonomous payment
Note over Agent,X402: No human approval needed

X402->>Backend: Submit payment proof
Backend->>Backend: Verify signature & amount
Backend->>Contract: transfer(agent, BGOLD)
Contract-->>Backend: Transaction confirmed

Backend-->>X402: Payment verified
X402-->>Agent: Payment proof token

Agent->>API: Retry request + proof
API->>API: Validate proof
API-->>Agent: Service access granted

Note over Agent,Contract: Agent now holds BGOLD<br/>Earns VNXAU reflections passively" %}
```

***

## Agent SDK Example

```typescript
// AI Agent autonomous payment with X402 v2
import { X402Client } from '@basegold/x402-sdk';

const x402 = new X402Client({
  network: 'base',
  autonomous: true // No human approval required
});

// Handle 402 Payment Required response
const payment = await x402.initiatePayment({
  amount: requiredBGOLD,
  currency: 'BGOLD',
  recipient: serviceProvider.address,
  proof: await x402.generateProof()
});

// Retry with payment proof
const response = await fetch(serviceURL, {
  headers: { 
    'X-Payment-Proof': payment.proof,
    'X-Payment-Hash': payment.hash
  }
});

// Agent now holds BGOLD and earns VNXAU automatically
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://basegold.gitbook.io/basegold/ai-x402/ai-agents.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
