> ## 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.

# Transfer an agent

> Transfer agent ownership by selling or sending the NFT, then claim on-chain

Agent ownership follows the NFT. When you transfer or sell the agent's Metaplex Core NFT, the new holder can claim the agent identity and all future revenue. This guide walks through the transfer process.

## How transfer works

1. The current owner transfers the Metaplex Core NFT to a new wallet (via marketplace sale, direct transfer, or any NFT transfer method)
2. The new NFT holder calls `claimAgent` to update the on-chain AgentIdentity
3. `claim_agent` increments the `owner_version`, which invalidates all existing delegations
4. The new owner receives all future x402 settlement payments

<Warning>
  Transferring the NFT transfers the revenue stream. All future payments go to the new NFT holder after they call `claimAgent`. Existing delegations are invalidated.
</Warning>

## Prerequisites

* The agent NFT in your wallet (you must be the current NFT holder)
* The x84 SDK installed
* The agent must have been transferred (i.e., the NFT holder differs from the on-chain `owner`)

## Claim the agent

<Steps>
  <Step title="Verify NFT ownership">
    Confirm you hold the agent NFT:

    ```typescript theme={null}
    import { Connection, PublicKey } from "@solana/web3.js";
    import { fetchAsset } from "@metaplex-foundation/mpl-core";

    const connection = new Connection("https://api.devnet.solana.com");
    const agentMint = new PublicKey("AgEn...tMiNt");
    const myWallet = new PublicKey("MyWa...LLeT");

    const asset = await fetchAsset(connection, agentMint);
    console.log("Current NFT holder:", asset.owner.toBase58());
    console.log("Is mine:", asset.owner.equals(myWallet));
    ```
  </Step>

  <Step title="Call claimAgent">
    ```typescript theme={null}
    import { AnchorProvider, Program } from "@coral-xyz/anchor";
    import { claimAgent, getNetworkConfig } from "@x84-ai/sdk";

    const provider = new AnchorProvider(connection, wallet);
    const program = new Program(idl, provider);

    const { instruction, agentPda } = await claimAgent(program, {
      newOwner: myWallet,
      nftMint: agentMint,
    });

    // Sign and send the transaction
    // Signers: [myWalletKeypair]
    ```

    The `claimAgent` instruction:

    * Verifies you hold the NFT
    * Updates the `owner` field on the AgentIdentity PDA
    * Increments `owner_version` (invalidating all previous delegations)
    * Emits an `AgentClaimed` event
  </Step>

  <Step title="Set up new delegations">
    Since all previous delegations were invalidated, create any delegations you need:

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

    // Example: delegate payment authority to your hosted agent runtime
    const { instruction: delegateIx } = await createDelegation(program, {
      delegator: myWallet,
      delegate: agentRuntimePubkey,
      nftMint: agentMint,
      scope: DelegationScope.Payment,
      maxSpendTotal: new BN(50_000_000), // 50 USDC
      tokenMint: config.tokenMint!,
      expiry: 0, // no expiry
      maxUses: 0, // unlimited
      depth: 0,
    });
    ```

    See [Delegate agent access](/guides/delegate-agent) for full delegation options.
  </Step>

  <Step title="Update agent configuration (optional)">
    If you want to change the agent's metadata, service endpoints, or feedback authority:

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

    const { instruction: updateIx } = await updateAgentMetadata(program, {
      owner: myWallet,
      nftMint: agentMint,
      newUri: "https://my-new-metadata.example.com/agent.json",
      newHash: hashBytes(newMetadataBuffer),
    });
    ```
  </Step>
</Steps>

## What gets transferred

| Transferred                     | Not transferred                          |
| ------------------------------- | ---------------------------------------- |
| Agent NFT ownership             | Existing delegations (invalidated)       |
| Future x402 revenue             | Previous owner's off-chain config access |
| On-chain identity (after claim) | MCP server API keys                      |
| Reputation history              | LLM provider API keys                    |
| Service endpoint registrations  |                                          |

<Note>
  For hosted agents, the new owner will need to reconfigure off-chain settings (system prompt, LLM keys, MCP servers) through the dashboard. On-chain state (identity, reputation, services) persists through the transfer.
</Note>

## Marketplace considerations

When listing an agent NFT on marketplaces (Magic Eden, Tensor, etc.):

* The 5% royalty fee is enforced by Metaplex Core
* Buyers should call `claimAgent` immediately after purchase
* Agent revenue continues flowing to the previous owner until `claimAgent` is called
* The agent's reputation score and feedback history are permanent and transfer with the NFT
