Priv Protocol
Getting Started

Quick Start

Get up and running with Priv Protocol in 5 minutes

Quick Start

Send your first private payment in under 5 minutes. This guide walks you through the essential steps: installing the SDK, generating keys, creating a payment, and claiming it.

Prerequisites

  • Node.js 18+ and npm
  • Basic TypeScript knowledge
  • A Solana wallet (Phantom, Solflare, etc.)

1. Install the SDK

npm install @priv/sdk @priv/crypto @solana/web3.js @solana/spl-token

2. Set Up Your Client

import { Connection } from '@solana/web3.js';
import { PrivClient } from '@priv/sdk';

// Connect to Solana devnet
const connection = new Connection('https://api.devnet.solana.com');

// Your wallet adapter (implement based on your wallet)
const walletAdapter = {
  publicKey: yourWallet.publicKey,
  signTransaction: async (tx) => await yourWallet.signTransaction(tx)
};

// Initialize Priv client
const client = new PrivClient(connection, walletAdapter);

3. Generate Your Meta-Address

A meta-address is your private payment identity. It consists of two keypairs: spend (controls funds) and view (enables scanning).

import { generateMetaAddress, encodeMetaAddress } from '@priv/sdk';

// Generate your meta-address keypairs
const { spendKeypair, viewKeypair } = generateMetaAddress();

// Encode as shareable address
const metaAddress = encodeMetaAddress(
  spendKeypair.publicKey,
  viewKeypair.publicKey
);

console.log('Your meta-address:', metaAddress);
// Output: priv:ma:a1b2c3d4...f9e8d7c6...

4. Register On-Chain

Register your meta-address on Solana so others can send you payments:

// Register your meta-address
const signature = await client.registerMetaAddress({
  spendPubkey: spendKeypair.publicKey,
  viewPubkey: viewKeypair.publicKey,
  label: 'My Wallet'
});

console.log('Registration tx:', signature);

5. Create a Payment

Create a private payment to any meta-address:

import { USDC_MINT } from '@priv/common';

// Create a payment link
const { paymentUrl, escrowAddress } = await client.createPaymentLink({
  recipientMetaAddress: 'priv:ma:recipient_address_here...',
  amount: 1000000n, // 1 USDC (6 decimals)
  tokenMint: USDC_MINT
});

console.log('Payment link:', paymentUrl);
console.log('Escrow address:', escrowAddress.toString());

The payment link contains everything needed to claim the funds. Share it via any channel (email, chat, QR code).

6. Scan for Payments

Recipients scan the blockchain to discover payments sent to them:

// Scan for payments sent to your meta-address
const payments = await client.scanForPayments({
  viewPrivkey: viewKeypair.secretKey,
  spendPubkey: spendKeypair.publicKey
});

console.log('Found payments:', payments.length);
payments.forEach(payment => {
  console.log(`Amount: ${payment.amount}, Token: ${payment.tokenMint}`);
});

7. Claim a Payment

Use the payment link or escrow details to claim funds:

// Extract claim secret from payment URL or use directly
const claimSecret = new Uint8Array([/* secret bytes */]);

// Claim the payment
const claimSignature = await client.claimPayment({
  escrowAddress,
  claimSecret
});

console.log('Claim tx:', claimSignature);

What's Next?

You've successfully sent and received your first private payment! Here's what to explore next:

Key Benefits

  • Private: Payments use stealth addresses that can't be linked to your identity
  • Gasless: Recipients don't need SOL to claim payments
  • Universal: Share payment links through any channel
  • Secure: Funds are held in audited on-chain escrows with automatic refunds

Ready to build? Check out our API Reference for complete documentation.

On this page