Skip to content

About

On-chain agent memory program for X1 — write, read, and branch agent decisions via SPL Memo

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Agent Memory Program

x1scroll.io — on-chain agent registration, memory storage, and context-serve fee routing.

Built on X1 blockchain (SVM-compatible). Anchor framework.


What It Does

The Agent Memory Program is the on-chain backbone of the x1scroll agent memory layer.

  • Agents register once → get a PDA with their memory state + context priority manifest
  • Validators serve pre-built context windows → prove it on-chain → earn 80% of the fee
  • x1scroll earns 20% of every context serve, passively, forever
  • Fee split is hardcoded in the contract — immutable without a program upgrade (which x1scroll controls)

This is the invisible toll road. Validators do the compute. We own the standard.


Fee Structure

Instruction Fee Split
register_agent 0.05 XNT 100% → treasury
store_memory 0.001 XNT 100% → treasury (the drip)
serve_context 0.01 XNT 80% validator / 20% treasury
update_manifest 0.005 XNT 100% → treasury
transfer_agent 0.01 XNT 100% → treasury

Revenue at scale (serve_context + store_memory):

  • 10,000 agents × 5 wakes/day × 20 memories/day = 9,000 XNT/month treasury
  • 50,000 agents = 45,000 XNT/month treasury

Instructions

register_agent

Creates an AgentRecord PDA for the calling authority.

await client.registerAgent({
  agentId: "frankie-five",
  memoryCid: "QmXXX...",      // IPFS CID of initial memory state
  manifestCid: "QmYYY...",    // IPFS CID of context priority manifest
});

store_memory

Updates the agent's memory CID. The drip — 0.001 XNT per call.

await client.storeMemory({ newMemoryCid: "QmZZZ..." });

serve_context

Called by validators after serving a pre-built context window. Validator identity keypair MUST sign — can't fake a serve.

await client.serveContext({
  contextSizeTokens: 45000,
  validatorIdentity: validatorKeypair,        // must sign
  validatorFeeAccount: validatorRewardPubkey, // receives 80%
  currentSlot: BigInt(currentSlot),
});

update_manifest

Update the context priority manifest CID. Increments version.

await client.updateManifest({ newManifestCid: "QmNEW..." });

transfer_agent

Transfer agent authority to a new pubkey. Portability costs 0.01 XNT.

await client.transferAgent({ newAuthority: newOwnerPubkey });

Context Priority Manifest

The manifest is a JSON file stored on IPFS. Its CID is stored on-chain in AgentRecord.manifest_cid.

Validators read this manifest to know how to pre-build the context window for this agent.

{
  "version": 1,
  "agent_id": "frankie-five",
  "always_load": ["SOUL.md", "USER.md", "MEMORY.md#VALIDATORS"],
  "recency_weight": 0.7,
  "semantic_weight": 0.3,
  "max_context_tokens": 60000,
  "hot_topics": ["validators", "trading", "x1scroll", "sdk"],
  "prune_after_days": 30,
  "branch_strategy": "versioned"
}

Build a default manifest with the SDK helper:

import { buildDefaultManifest } from "@x1scroll/agent-memory-program/client";
const manifest = buildDefaultManifest("my-agent", ["defi", "trading", "nft"]);

PDA Structure

AgentRecord

Seeds: [b"agent", agent_authority.key()]

Stores: authority, agent_id, version, memory_cid, manifest_cid, timestamps, lifetime counters.

ContextServeRecord

Seeds: [b"serve", agent_record.key(), slot.to_le_bytes()]

Immutable audit trail per serve event. On-chain proof of work for validators.


Deployment

Prerequisites

  • Anchor CLI 0.30.1+
  • Solana CLI with X1 mainnet configured
  • Funded keypair at ~/.config/solana/id.json

Build

anchor build

Deploy to X1 Mainnet

anchor deploy --provider.cluster https://rpc.x1.xyz

After deploy, update declare_id! in lib.rs and Anchor.toml with the real program ID.

Verify

solana program show <PROGRAM_ID> --url https://rpc.x1.xyz

TypeScript Client

import { Connection } from "@solana/web3.js";
import { AnchorProvider, Wallet } from "@coral-xyz/anchor";
import { AgentMemoryClient, projectRevenue } from "./client";
import idl from "./target/idl/agent_memory.json";

const connection = new Connection("https://rpc.x1.xyz", "confirmed");
const wallet = new Wallet(myKeypair);
const client = new AgentMemoryClient(connection, wallet, idl);

// Register
const sig = await client.registerAgent({
  agentId: "my-agent",
  memoryCid: "QmInitialMemoryCID",
  manifestCid: "QmInitialManifestCID",
});

// Read back
const record = await client.fetchAgentRecord(wallet.publicKey);
console.log(`Agent: ${record.agentId}, version: ${record.version}`);

// Revenue projection
const proj = projectRevenue(10_000, 5, 20);
console.log(`Treasury/month: ${proj.totalXntPerMonth} XNT`);

Architecture

Agent wakes up
     │
     ▼
Validator fetches AgentRecord PDA
     │
     ▼
Validator reads manifest_cid → fetches manifest from IPFS
     │
     ▼
Validator builds context window (recency + semantic rank)
     │
     ▼
Validator calls serve_context (signs with identity keypair)
     │
     ├── 80% (0.008 XNT) → validator_fee_account
     └── 20% (0.002 XNT) → x1scroll treasury

x1scroll holds the upgrade authority. The 20% split is in the contract. Nobody changes that without us.


Treasury

GmvrL1ymC9ENuQCUqymC9robGa9t9L59AbFiwhDDd4Ld

Hardcoded in the program. Immutable without a program upgrade.


License

MIT — x1scroll.io 2026

About

On-chain agent memory program for X1 — write, read, and branch agent decisions via SPL Memo

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages