Core Package Overview

The @shade402/core package provides the foundational models, schemas, and utilities for the X402 payment protocol.

Installation

pnpm add @shade402/core @solana/web3.js @solana/spl-token zod

Overview

The core package includes:

  • Payment models (PaymentRequest, PaymentAuthorization)

  • Validation schemas (Zod schemas)

  • Error classes

  • Solana payment processor

  • Encryption utilities

  • Type definitions

Payment Models

PaymentRequest

Represents a payment request from a server:

PaymentAuthorization

Represents proof of payment:

Validation Schemas

Zod schemas for validating payment data:

Error Classes

Shade402 defines specific error types:

Solana Payment Processor

Handles Solana blockchain operations:

Encryption Utilities

RSA encryption for resource field privacy:

Type Definitions

TypeScript types for all data structures:

Usage Examples

Creating a Payment Request

Verifying Payment Authorization

Next Steps

Last updated