Developers · BRC-100

BRC-100 PeerPay

SpiffyVault speaks PeerPay, the wallet-to-wallet payment of BRC-100 wallets such as BSV Desktop and BSV Browser. A web wallet, an Electron wallet or a service that uses the BSV SDK can pay a SpiffyVault user, and get paid by one, with the standard @bsv/message-box-client package.

How it works

The payment waits in the message box, so the payee does not have to be online. PeerPayClient does all of this for you.

The payment key

The payment key is a compressed secp256k1 public key: 66 hex characters, starting with 02 or 03. A SpiffyVault user shares it from Get paid, with Who will scan it? › Other BRC-100 wallet and Share key. It is also the k value of their payment link.

The payment key is not the user's sign-in identity. Sign-in gives you an Ed25519 key; PeerPay uses this secp256k1 key. Nothing in SpiffyVault links the two for you.

The message box host

SpiffyVault sends and collects PeerPay payments at the public message box server that the BSV Association runs:

https://messagebox.bsvblockchain.tech

Pay a SpiffyVault user

import { WalletClient } from '@bsv/sdk';
import { PeerPayClient } from '@bsv/message-box-client';

const peerPay = new PeerPayClient({
  walletClient: new WalletClient(),
  messageBoxHost: 'https://messagebox.bsvblockchain.tech',
});

// The key the payee shared. On testnet: 'testnet:02…' without 'testnet:'.
const recipient = '02…';
await peerPay.sendPayment({ recipient, amount: 25000 }); // satoshis

The SpiffyVault user sees the payment when the app next collects from the message box: when it starts, and about every 30 seconds while it runs.

Get paid by SpiffyVault

Give the SpiffyVault user your wallet's identity key: they scan it as a QR code, or paste it under Scan › Paste a code or key. SpiffyVault pays it over PeerPay. Then collect the payment:

const incoming = await peerPay.listIncomingPayments();
for (const payment of incoming) {
  await peerPay.acceptPayment(payment);
}

On testnet, give your key as testnet:02…. A SpiffyVault on testnet refuses a bare key, because a bare key is a mainnet key.

The paying SpiffyVault signs in to the message box with its own BRC-100 payment key. Without one it says that no BRC-100 identity was found. The user sets it up from their avatar, under Identity & keys › BRC-100 payment key › Set up.

Without a BRC-100 wallet

A page or a service with only a private key can collect PeerPay payments too. acceptPeerPayPayments in @spiffyvault/payments reads the inbox as SpiffyVault does:

import { ProtoWallet, PrivateKey } from '@bsv/sdk';
import { acceptPeerPayPayments } from '@spiffyvault/payments';

const payee = await acceptPeerPayPayments({
  network: 'testnet',
  wallet: new ProtoWallet(PrivateKey.fromHex(keyHex)), // its identity key is your payment key
  onPayment: async p => keep(p), // checked and on the network: keep p.atomicBeef and p.outputs
});

To read the inbox yourself instead, use MessageBoxClient from @bsv/message-box-client with a ProtoWallet. Use listMessagesLite and pass the host on every call: listMessages tries to take the payment into a full BRC-100 wallet, which a ProtoWallet is not.

Limits