Quickstart Guide

Get started with PEAC Protocol in minutes. Add cryptographic receipts to any HTTP response with just a few lines of code.

Prerequisites

Node.js 20+
ESM support
TypeScript recommended

Installation

# Install PEAC Protocol core library
pnpm add @peac/core

# Or with npm
npm install @peac/core

# Or with yarn
yarn add @peac/core

1. Generate Key Pair

import { generateKeyPair } from '@peac/core'

// Generate Ed25519 key pair
const { publicKey, privateKey } = await generateKeyPair()

// Save your private key securely (environment variable)
console.log('Private key:', privateKey)
console.log('Public key:', publicKey)

2. Create and Sign Receipt

import { signReceipt } from '@peac/core'

// Create receipt payload
const payload = {
  iat: Math.floor(Date.now() / 1000),
  hash: 'sha256:a1b2c3d4e5f6...',  // Content hash
  aipref: { url: 'https://yoursite.com/.well-known/ai-preferences.txt' }
}

// Sign the receipt
const receipt = await signReceipt(payload, {
  privateKey: process.env.PEAC_PRIVATE_KEY,
  keyId: 'peac-2025-09'
})

console.log('PEAC-Receipt:', receipt)

3. Add to HTTP Response

// Express.js example
app.get('/api/content', async (req, res) => {
  const content = { data: 'Your content here' }

  // Create receipt for this response
  const receipt = await signReceipt({
    iat: Math.floor(Date.now() / 1000),
    hash: createHash('sha256').update(JSON.stringify(content)).digest('hex'),
    aipref: { url: 'https://yoursite.com/.well-known/ai-preferences.txt' }
  }, {
    privateKey: process.env.PEAC_PRIVATE_KEY,
    keyId: 'peac-2025-09'
  })

  // Set PEAC-Receipt header
  res.setHeader('PEAC-Receipt', receipt)
  res.json(content)
})

Go-Live Checklist

1
Create /.well-known/peac.txt policy file (≤20 lines)
2
Publish JWKS at /.well-known/jwks.json
3
Set appropriate Cache-Control headers for policy files
4
Implement key rotation strategy
5
Add PEAC-Receipt to all relevant API responses
6
Test receipt verification in your client applications
7
Monitor receipt validation errors and timing

Next Steps

Complete API Reference

Detailed field documentation and examples

View API Docs →

Test in Browser

Decode and verify receipts instantly

Try Playground →

Payment Adapters

x402 and other payment integration guides

Payment Setup →