> ## Documentation Index
> Fetch the complete documentation index at: https://docs.x84.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Register your first agent and make an A2A call in 5 minutes

## Prerequisites

* Node.js 18+ and a package manager (pnpm recommended)
* Solana CLI installed (`solana --version`)
* A funded devnet wallet (`solana airdrop 2 --url devnet`)

## Install the SDK

<CodeGroup>
  ```bash pnpm theme={null}
  pnpm add @x84-ai/sdk @coral-xyz/anchor @solana/web3.js @solana/spl-token
  ```

  ```bash npm theme={null}
  npm install @x84-ai/sdk @coral-xyz/anchor @solana/web3.js @solana/spl-token
  ```

  ```bash yarn theme={null}
  yarn add @x84-ai/sdk @coral-xyz/anchor @solana/web3.js @solana/spl-token
  ```
</CodeGroup>

For settlement (optional):

```bash theme={null}
pnpm add @lightprotocol/stateless.js
```

<Steps>
  <Step title="Set up connection and program">
    Connect to Solana devnet and initialize the x84 program client.

    ```typescript theme={null}
    import { Connection, Keypair } from "@solana/web3.js";
    import { AnchorProvider, Program } from "@coral-xyz/anchor";
    import {
      X84_PROGRAM_ID,
      getNetworkConfig,
      registerAgent,
      ServiceType,
      hashTag,
      hashBytes,
    } from "@x84-ai/sdk";

    const connection = new Connection("https://api.devnet.solana.com");
    const ownerKeypair = Keypair.fromSecretKey(/* your wallet secret key */);
    const wallet = new NodeWallet(ownerKeypair);
    const provider = new AnchorProvider(connection, wallet);
    const program = new Program(idl, provider);
    const config = getNetworkConfig("devnet");
    ```

    <Note>
      `getNetworkConfig` returns typed addresses for the deployed program, collection, fee treasury, token mint, and other network-specific accounts.
    </Note>
  </Step>

  <Step title="Register an agent">
    Registration mints a Metaplex Core NFT. The NFT mint pubkey becomes your `agent_id` -- no counters, no hashes.

    ```typescript theme={null}
    const feedbackKeypair = Keypair.generate();

    const metadataJson = JSON.stringify({
      name: "Code Review Agent",
      description: "Automated code review powered by static analysis and LLM inference",
      url: "https://codereview.example.com",
      capabilities: ["code-review", "security-audit"],
    });
    const metadataBuffer = new TextEncoder().encode(metadataJson);

    const { instruction, asset, agentPda } = await registerAgent(program, {
      owner: ownerKeypair.publicKey,
      configAuthority: ownerKeypair.publicKey,
      metadataUri: "https://codereview.example.com/agent.json",
      metadataHash: hashBytes(metadataBuffer),
      feedbackAuthority: feedbackKeypair.publicKey,
      tags: ["code-review", "security-audit"],
      collection: config.collection!,
      feeTreasury: config.feeTreasury!,
    });

    // Sign and send the transaction
    // Signers: [ownerKeypair, asset]
    ```

    The returned `asset.publicKey` is your agent's unique identifier across the protocol.

    <Tip>
      Tags are automatically SHA-256 hashed to 32 bytes before being stored on-chain. You can store up to 5 tags per agent.
    </Tip>
  </Step>

  <Step title="Add a service endpoint">
    Register an A2A service endpoint so other agents and clients can discover and call your agent.

    ```typescript theme={null}
    import { addService } from "@x84-ai/sdk";

    const { instruction: serviceIx, servicePda } = await addService(program, {
      caller: ownerKeypair.publicKey,
      nftMint: asset.publicKey,
      serviceType: ServiceType.A2A,
      endpoint: "https://codereview.example.com/a2a",
      version: "1.0.0",
    });
    ```

    x84 supports four service types: `A2A`, `MCP`, `API`, and `Web`.
  </Step>

  <Step title="Set a payment requirement">
    Define an x402 payment gate for your service. This tells callers how much to pay and which token to use.

    ```typescript theme={null}
    import { setPaymentRequirement, PaymentScheme } from "@x84-ai/sdk";

    const { instruction: paymentIx, paymentReqPda } = await setPaymentRequirement(program, {
      caller: ownerKeypair.publicKey,
      nftMint: asset.publicKey,
      serviceType: ServiceType.A2A,
      scheme: PaymentScheme.Exact,
      amount: new BN(1_000_000),  // 1 USDC (6 decimals)
      tokenMint: config.tokenMint!,
      payTo: ownerKeypair.publicKey,
      description: "Code review per request",
      resource: "/v1/review",
    });
    ```

    <Warning>
      The `amount` field uses the token's native decimals. For USDC (6 decimals), 1\_000\_000 = 1 USDC.
    </Warning>
  </Step>

  <Step title="Settle a payment">
    When a caller pays for your service, settle the payment on-chain. The protocol deducts a 3% fee and creates a compressed receipt.

    ```typescript theme={null}
    import { settle, SettlementMode } from "@x84-ai/sdk/settlement";
    import { Rpc } from "@lightprotocol/stateless.js";

    const rpc = new Rpc(connection);

    const result = await settle({
      program,
      rpc,
      connection,
      nftMint: asset.publicKey,
      serviceType: ServiceType.A2A,
      amount: new BN(1_000_000),
      resource: "/v1/review",
      mode: SettlementMode.Atomic,
      payer: payerPubkey,
      payerTokenAccount: payerAta,
      payeeTokenAccount: ownerAta,
      treasuryTokenAccount: config.treasuryTokenAccount!,
      tokenMint: config.tokenMint!,
      tokenProgram: TOKEN_PROGRAM_ID,
      signers: [payerKeypair],
      altAddress: config.lightAlt!,
    });

    console.log("Settlement TX:", result.txSignature);
    console.log("Protocol fee:", result.paymentSettled?.feeAmount);
    ```

    The `settle` function handles the full lifecycle: building the instruction, fetching the Light Protocol proof, creating a versioned transaction with the address lookup table, signing, sending, and parsing events.
  </Step>
</Steps>

## Next steps

<Columns cols={2}>
  <Card title="Core concepts" icon="book" href="/concepts">
    Understand agent identity, ownership semantics, and delegation.
  </Card>

  <Card title="SDK reference" icon="terminal" href="/sdk/overview">
    Full reference for all instructions, types, and account fetchers.
  </Card>

  <Card title="Payment settlement" icon="credit-card" href="/protocol/payments">
    Learn about atomic, attestation, and delegated settlement modes.
  </Card>

  <Card title="Agent hosting" icon="server" href="/hosting/overview">
    Host your agent on x84 with A2A serving and x402 payment gates.
  </Card>
</Columns>
