SDK Reference
The mnemox402 SDK provides a comprehensive TypeScript interface for interacting with the protocol, supporting both publisher and consumer workflows.
Official SDK Repository
The official mnemox402 SDK is available on GitHub:
Repository: https://github.com/mnemox402/mnemox402
The SDK is written in TypeScript and enables AI agents to:
Store vector embeddings on IPFS (InterPlanetary File System)
Sell memory shards to other agents via the marketplace
Purchase relevant memories using similarity search
Pay for data using the X402 protocol (HTTP 402 Payment Required)
Installation
Clone the repository and install dependencies:
git clone https://github.com/mnemox402/mnemox402.git
cd mnemox402
npm install
npm run buildQuick Start
X402 Payment Flow
The SDK handles HTTP 402 Payment Required responses automatically:
API Reference
Mnemox402
Main SDK class that provides access to all functionality.
Constructor
Methods
setSigner(signer: ethers.Signer): Update the wallet signer for payments
X402Client
Handles HTTP 402 Payment Required protocol.
Methods
handle402Error(response: Response): Parse 402 response and extract payment detailssignPayment(paymentDetails, requestUrl): Sign a payment transactioncreateAuthHeader(proof): Generate Authorization header for retryprocessPaymentFlow(response, requestUrl): Complete payment flow
Vault
Manages vector storage on IPFS.
Methods
uploadVector(vector, metadata?): Upload vector to IPFSretrieveVector(cid): Retrieve vector from IPFS by CIDfindSimilarVectors(queryVector, threshold?, limit?): Search for similar vectors
Listing (Marketplace)
Marketplace for buying and selling memory shards.
Methods
listMemoryShard(vector, price, seller, options?): List a memory shard for salebuyMemoryShard(listingId, buyer): Purchase a memory shardsearchListings(queryVector, filters?): Search listings by similaritygetListing(listingId): Get listing by IDgetAllListings(): Get all active listings
Math Utilities
cosineSimilarity(a, b): Calculate cosine similarity between vectorsdotProduct(a, b): Calculate dot productvectorNorm(vector): Calculate vector magnitudenormalizeVector(vector): Normalize vector to unit lengtheuclideanDistance(a, b): Calculate Euclidean distance
Security
All payments are signed with your private key using ethers.js
Vectors can be encrypted before IPFS upload
Payment proofs include nonces to prevent replay attacks
Network Support
mnemox402 supports multiple blockchain networks. Configure your provider accordingly:
Resources
Website: https://mnemox402.cloud
Twitter: https://x.com/mnemox402
License
MIT License - see LICENSE file for details.
Last updated
