Beersy
BRC-5

HTTP Wallet Communications Substrate

A wallet running on your own machine and a website open in your browser have no natural way to talk to each other. This defines one over ordinary web requests, so any application can reach any wallet on the same device without either side having been built for the other.

Brayden Langley, Ty Everettchanged 1 May 20264 min read
appappappwallet

Summary

Why
Wallets each spoke their own API, so apps could not talk to more than one wallet without writing custom code for each.
What
BRC-5 defines two localhost HTTP , a binary wire and a JSON API, that let an application call any BRC-100 wallet method by posting to a route named after that method.
How
A developer sends a POST request to a local address such as http://localhost:3321/, with either JSON arguments or raw binary bytes as the body, and gets back the wallet's JSON or binary result for that BRC-100 method.

What this lets you do

  • Call any BRC-100 wallet method over plain HTTP
  • Choose JSON or binary encoding depending on what the client needs
  • Reach a wallet at a fixed localhost address without custom per-wallet code
  • Send the calling app's origin so the wallet knows who is asking
  • Swap wallets without changing how the app talks to them

Written by claude-sonnet-5 from the specification text. Where the two differ, the original is correct.

Reference for an AI

Everything an assistant needs to answer questions about BRC-5 accurately, including what it depends on.

The specification

Abstract

The Bitcoin Wallet HTTP Interface is a standard interface that enables applications to connect with Bitcoin wallets to facilitate certain functionality. The interface provides a unified way for applications to request the creation of a Bitcoin transaction, encryption, digital signature creation, and other features provided by the wallet. By standardizing the interface, applications can support multiple wallets and give the user greater control over their Bitcoin-related activities.

Motivation

The motivation for this standard interface is to provide a common way for applications to connect with Bitcoin wallets. Currently, many Bitcoin wallets provide their own APIs, which makes it difficult for applications to support multiple wallets. The Bitcoin Wallet HTTP Interface standardizes the way that applications can interact with wallets, enabling them to be more easily integrated into various applications. This interface is designed to be flexible enough to support a range of wallets and use cases, while also providing a secure and standardized method of communication.

Status Note

This document originally described the pre-BRC-100 localhost HTTP API. The /v1/... routes, mixed GET/POST method table, and legacy method names such as createCertificate and findCertificates are historical. Current interoperable implementations in bsv-blockchain/ts-sdk expose the BRC-100 over HTTP without a versioned URL prefix.

Implementers SHOULD use the current substrates below for new work. The older route table is deprecated except where a deployment explicitly maintains backwards compatibility with legacy wallets.

Specification

Current wallet HTTP interoperability is defined by two localhost substrates for the BRC-100 wallet interface:

  1. Binary wallet wire

    • Default base URL: http://localhost:3301
    • Route: POST /<BRC-100 methodName>
    • Request body: application/octet-stream
    • Body framing: the BRC-100 wallet-wire parameter payload for the selected method, excluding the method call code and originator frame that are used by the client-side substrate to choose the route and Origin header.
    • Originator: conveyed through the HTTP Origin header when available.
  2. JSON wallet API

    • Default base URL: http://localhost:3321
    • Secure development base URL: https://localhost:2121
    • Route: POST /<BRC-100 methodName>
    • Request body: JSON arguments for the BRC-100 method
    • Response body: JSON result
    • Originator: Node clients may set Origin and Originator; browser clients rely on the browser-managed Origin header.

No /v1 prefix is used by the current ts-sdk HTTP wallet substrates.

Standard HTTP Routes

Every current BRC-100 wallet method is addressed by its method name:

RouteRequest MethodSubstrate
/createActionPOSTBinary wire or JSON
/signActionPOSTBinary wire or JSON
/abortActionPOSTBinary wire or JSON
/listActionsPOSTBinary wire or JSON
/internalizeActionPOSTBinary wire or JSON
/listOutputsPOSTBinary wire or JSON
/relinquishOutputPOSTBinary wire or JSON
/getPublicKeyPOSTBinary wire or JSON
/revealCounterpartyKeyLinkagePOSTBinary wire or JSON
/revealSpecificKeyLinkagePOSTBinary wire or JSON
/encryptPOSTBinary wire or JSON
/decryptPOSTBinary wire or JSON
/createHmacPOSTBinary wire or JSON
/verifyHmacPOSTBinary wire or JSON
/createSignaturePOSTBinary wire or JSON
/verifySignaturePOSTBinary wire or JSON
/acquireCertificatePOSTBinary wire or JSON
/listCertificatesPOSTBinary wire or JSON
/proveCertificatePOSTBinary wire or JSON
/relinquishCertificatePOSTBinary wire or JSON
/discoverByIdentityKeyPOSTBinary wire or JSON
/discoverByAttributesPOSTBinary wire or JSON
/isAuthenticatedPOSTBinary wire or JSON
/waitForAuthenticationPOSTBinary wire or JSON
/getHeightPOSTBinary wire or JSON
/getHeaderForHeightPOSTBinary wire or JSON
/getNetworkPOSTBinary wire or JSON
/getVersionPOSTBinary wire or JSON

The method names, argument structures, result structures, and binary call codes are specified normatively in BRC-100.

JSON Code Example

const httpResult = await makeHttpRequest(
  'http://localhost:3321/createAction',
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      description: 'Create a wallet action',
      outputs: []
    })
  }
)

Binary-Wire Code Example

const httpResult = await makeHttpRequest(
  'http://localhost:3301/createAction',
  {
    method: 'POST',
    headers: {
      'Content-Type': 'application/octet-stream'
    },
    body: walletWireParameterBytes
  }
)

Implementation

Applications and wallets should implement the current BRC-100 method set and one or more of the current HTTP substrates above. The current reference implementation is the bsv-blockchain/ts-sdk wallet substrate implementation.

Was this helpful?

Search Beersy

Search standards by number, title, author or topic