Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

PEAC Hello World

Generate a keypair, sign a receipt, verify it offline. Under 10 lines of logic.

Run (in monorepo)

cd examples/hello-world
pnpm demo

Run standalone (outside monorepo)

mkdir peac-hello && cd peac-hello
npm init -y
npm install @peac/crypto @peac/protocol tsx typescript

Create demo.ts:

import { generateKeypair } from '@peac/crypto';
import { issue, verifyLocal } from '@peac/protocol';

const { publicKey, privateKey } = await generateKeypair();

const { jws } = await issue({
  iss: 'https://api.example.com',
  kind: 'evidence',
  type: 'org.peacprotocol/payment',
  pillars: ['commerce'],
  extensions: {
    'org.peacprotocol/commerce': {
      payment_rail: 'stripe',
      amount_minor: '10000',
      currency: 'USD',
    },
  },
  privateKey,
  kid: 'demo-key',
});

const result = await verifyLocal(jws, publicKey);
console.log('Valid:', result.valid);

Run:

npx tsx demo.ts

Expected output:

Receipt JWS: eyJhbGciOiJFZERTQSIsInR5cCI6ImludGVyYWN0aW9uLXJl...
Valid: true
Issuer: https://api.example.com
Kind: evidence

With MCP Server

Add the MCP server to Claude Desktop or Cursor, then ask your agent:

"Verify this PEAC receipt: eyJhbGci..."

See the MCP server README for setup instructions.

Links