Introduction

Apostolos Protocol
Documentation

Apostolos is a fully on-chain cultural data protocol for encoding, preserving, and exchanging digital artifacts as cryptographic objects. This documentation covers the protocol architecture, SDK, and integration guides.

Quickstart

Get started with Apostolos in under 5 minutes. Install the SDK, initialize a client, and inscribe your first artifact on-chain.

1. Install

bash
npm install @apostolos/sdk

2. Initialize

javascript
import { Apostolos } from "@apostolos/sdk";

const client = new Apostolos({
  network: "mainnet",       // or "testnet"
  privateKey: process.env.PRIVATE_KEY,
});

3. Inscribe an artifact

javascript
const artifact = await client.encode({
  data: fs.readFileSync("./artwork.png"),
  mimeType: "image/png",
  metadata: {
    title: "Genesis Object #001",
    creator: "0xYourAddress",
  },
});

console.log(artifact.id); // on-chain artifact ID
You can use the testnet network to inscribe artifacts without spending real funds during development.

Installation

Apostolos SDK supports Node.js 18+ and modern browsers via ESM.

npm

bash
npm install @apostolos/sdk

yarn

bash
yarn add @apostolos/sdk

pnpm

bash
pnpm add @apostolos/sdk

Environment Variables

bash
APOSTOLOS_NETWORK=mainnet
APOSTOLOS_PRIVATE_KEY=your_private_key_here
APOSTOLOS_RPC_URL=https://rpc.apostolos.xyz
Never commit your private key to version control. Use .env.local or a secrets manager.

On-Chain Encoding

Apostolos encodes artifact data directly into immutable blockchain state. Unlike NFTs that store a URL pointing to off-chain data, Apostolos artifacts are the data no external dependencies, no fragile pointers.

How it works

When you call encode(), the protocol:

  1. Chunks the artifact data into protocol-defined segments
  2. Embeds each segment into transaction calldata or inscription slots
  3. Assembles an on-chain index pointing to each segment
  4. Issues a cryptographic artifact ID tied to the complete data hash
javascript
const artifact = await client.encode({
  data: Buffer,           // raw artifact bytes
  mimeType: string,       // MIME type of the artifact
  metadata: {
    title: string,
    creator: string,      // wallet address
    tags?: string[],
  },
  privacy?: "public" | "zk-shielded",  // default: "public"
});

// Returns:
// {
//   id: string,          // on-chain artifact ID
//   txHash: string,      // inscription transaction hash
//   size: number,        // encoded byte size
//   timestamp: number,
// }
Artifact size limits depend on the underlying chain. On supported L2s, artifacts up to 10MB are supported in a single inscription.

ZK Ownership

Zero-knowledge proofs allow collectors to own, transfer, and prove provenance of artifacts without revealing their identity on-chain.

Ownership model

Every artifact has an associated ownership commitment a cryptographic hash of owner_address + artifact_id + salt. The commitment is stored on-chain; the preimage remains private.

Shielded transfer

javascript
const proof = await client.transfer({
  artifactId: "art_abc123",
  recipient: "0xRecipientAddress",
  zkMode: true,           // generates ZK proof of ownership
});

// proof.receipt on-chain transfer receipt
// proof.zkProof verifiable ZK proof for recipient

Proving ownership to a verifier

javascript
const isOwner = await client.verify({
  artifactId: "art_abc123",
  proof: proof.zkProof,
});

console.log(isOwner); // true

x402 Micropayments

x402 is an HTTP-native micropayment standard built into the Apostolos protocol. It enables pay-per-access, licensing, and artifact exchange with sub-second settlement no external payment infrastructure needed.

Payment flow

  1. Client requests access to a gated artifact
  2. Server responds with 402 Payment Required + payment details
  3. Client signs and submits micropayment on-chain
  4. Server verifies payment and grants access
javascript
// Gating an artifact with x402
const gate = await client.pay.createGate({
  artifactId: "art_abc123",
  price: "0.001",          // in protocol token
  currency: "USDC",
  access: "single-view",   // or "permanent"
});

// Accessing a gated artifact
const access = await client.pay.unlock({
  gateId: gate.id,
  payer: "0xYourAddress",
});

console.log(access.contentUrl);
x402 payments settle on-chain within ~1 second on supported L2 networks.

Provenance

Every Apostolos artifact carries an immutable chain of custody from the original inscription through every transfer. Provenance is cryptographically verifiable and cannot be forged or altered.

Querying provenance

javascript
const history = await client.provenance("art_abc123");

// Returns array of events:
// [
//   { event: "inscribed", address: "0x...", timestamp: ... },
//   { event: "transferred", from: "0x...", to: "0x...", ... },
//   { event: "licensed", licensee: "0x...", ... },
// ]

SDK Installation

The Apostolos SDK is available for JavaScript/TypeScript. Additional language SDKs (Python, Rust) are in development.

bash
npm install @apostolos/sdk

TypeScript support

The SDK ships with full TypeScript definitions. No additional @types package needed.

typescript
import { Apostolos, ArtifactMetadata, EncodeResult } from "@apostolos/sdk";

encode()

Inscribes artifact data directly on-chain and returns a permanent artifact ID.

javascript
const result = await client.encode({
  data: fs.readFileSync("artifact.mp4"),
  mimeType: "video/mp4",
  metadata: { title: "Archive Reel #01", creator: "0xYour" },
});

transfer()

Transfers ownership of an artifact to a new address, with optional ZK privacy.

javascript
const tx = await client.transfer({
  artifactId: "art_abc123",
  recipient: "0xRecipient",
  zkMode: true,
});

verify()

Verifies ownership or provenance of an artifact using a ZK proof.

javascript
const valid = await client.verify({
  artifactId: "art_abc123",
  proof: zkProof,
});

pay()

x402 micropayment utilities for gating and unlocking artifact access.

javascript
// Create gate
const gate = await client.pay.createGate({
  artifactId: "art_abc123",
  price: "0.50",
  currency: "USDC",
  access: "permanent",
});

// Unlock
const grant = await client.pay.unlock({
  gateId: gate.id,
  payer: "0xYourAddress",
});

Architecture Overview

Apostolos is a three-layer protocol stack. Each layer is independently composable and can be used without the others.

Layer 1
On-Chain Encoding
Artifact data is chunked and inscribed directly into blockchain state. The encoding layer handles chunking, indexing, and integrity verification.
Layer 2
ZK Ownership & Transfer
A zero-knowledge ownership model sits on top of encoded artifacts, enabling private ownership, private transfer, and selective disclosure of provenance.
Layer 3
x402 Commerce
Protocol-native micropayment rails built on the x402 standard. Enables pay-per-access, licensing, and artifact exchange with on-chain settlement.

Data Model

An Apostolos artifact is composed of four components stored on-chain.

typescript
type Artifact = {
  id: string;                  // unique on-chain artifact ID
  dataHash: string;            // keccak256 of raw artifact bytes
  segments: Segment[];         // on-chain encoded data segments
  metadata: ArtifactMetadata;  // title, creator, mimeType, tags
  ownershipCommitment: string; // ZK ownership commitment hash
  provenanceRoot: string;      // merkle root of transfer history
  createdAt: number;           // block timestamp of inscription
};

type ArtifactMetadata = {
  title: string;
  creator: string;          // wallet address
  mimeType: string;
  tags?: string[];
};

Security Model

Apostolos inherits the security guarantees of the underlying blockchain and augments them with zero-knowledge proofs for ownership privacy.

Threat model

Data integrity
Artifact data is hash-committed on inscription. Any mutation is detectable on-chain data is immutable by protocol.
Ownership privacy
ZK proofs reveal nothing about the owner's identity beyond the validity of the commitment. The proof system is based on Groth16.
Provenance forgery
Transfer events are chained via a Merkle root. Inserting or removing events from history is computationally infeasible.
Payment safety
x402 payments are atomic funds and access grants settle in the same transaction. No partial states.
The ZK proof system is currently in audited beta. See the audit report on GitHub before using in production with high-value artifacts.