Window Wallet Communication Substrate
Some wallets live inside the browser itself rather than running as a separate program. This gives applications one way to reach those, so a developer writes the same code regardless of where the user's wallet actually runs.
Summary
- Why
- Web apps needed a way to reach wallet functions like signing and encryption without launching a separate wallet program and bouncing the user between windows.
- What
- BRC-7 defines a global `window.CWI` object that browser-embedded Bitcoin wallets expose so web pages can call wallet functions directly.
- How
- A wallet-enabled browser attaches a `CWI` object to `window` once the user is authenticated, and the page calls methods like `window.CWI.createAction()` or `window.CWI.encrypt({...})`, passing required parameters as a single object.
What this lets you do
- create a Bitcoin transaction from a web page
- encrypt or decrypt data via the wallet
- create or verify a digital signature
- create or check a certificate
- check network, version, or authentication status
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-7 accurately, including what it depends on.
The specification
Abstract
The Window Wallet Communication Substrate is a standardized interface that enables seamless integration between web applications and browser embedded Bitcoin wallets. It serves as a unified gateway for applications to access various wallet functionalities, including the creation of Bitcoin transactions, encryption, digital signature creation, and more. By establishing this standardized interface, applications gain the ability to support multiple wallet providers, enhancing flexibility and choice for users in managing their Bitcoin-related tasks. This interface empowers users with greater control and accessibility while maintaining compatibility across different applications and wallets.
Motivation
The motivation behind this standard is to enable web browsers to directly integrate Bitcoin wallet functionality without relying on an additional application running on the client's device.
Although BRC-5 defines a standard for local communication over HTTP, integrating wallet functionality in the browser eliminates the need for external wallet applications, reducing the overhead of inter-process communication and network requests.
This also eliminates the need for users to switch between multiple applications when approving permissions, creating transactions, etc. They can perform all wallet-related tasks within the web application they are already using, resulting in a more cohesive and convenient user experience.
Status Note
The window.CWI substrate remains relevant, but this document's BRC-56 function table is historical. Current browser wallet injections SHOULD expose the BRC-100 wallet method set. Legacy function names such as window.CWI.createCertificate() and window.CWI.findCertificates are deprecated for new implementations; use acquireCertificate and listCertificates.
Specification
We define a specification for providing access to Bitcoin wallet functionality via the global window object that is directly available in all standard browser implementations.
Once the browser has verified that the user is authenticated, an object labeled CWI should be added to the window object to provide access to the standard wallet functionality as defined by BRC-56.
Standard CWI Functions Associated with Various Message Types
For each of the message pairs (request and response) incorporated into BRC-56, we specify the existence of a corresponding message type with a specific function name:
| Message Type | Window Function Name Value |
|---|---|
| BRC-1 Transaction Creation | window.CWI.createAction() |
| BRC-2 Encryption | window.CWI.encrypt() |
| BRC-2 Decryption | window.CWI.decrypt() |
| BRC-3 Signature Creation | window.CWI.createSignature() |
| BRC-3 Signature Verification | window.CWI.verifySignature() |
| BRC-53 Certificate Creation | window.CWI.createCertificate() |
| BRC-53 Certificate Verification | window.CWI.proveCertificate() |
| BRC-56 HMAC Creation | window.CWI.createHmac() |
| BRC-56 HMAC Verification | window.CWI.verifyHmac() |
| BRC-56 Public Key Derivation | window.CWI.getPublicKey() |
| BRC-56 Certificate List | window.CWI.findCertificates |
| BRC-56 Version Request | window.CWI.getVersion() |
| BRC-56 Network Request | window.CWI.getNetwork() |
| BRC-56 Authentication Request | window.CWI.isAuthenticated() |
| BRC-56 Async Auth Request | window.CWI.waitForAuthentication() |
This will allow applications to call functions with the following syntax:
window.CWI.<functionName>
Parameter Format Specification
We specify that all required parameters are provided in an object to the CWI functions.
Example Identity Key Request
const identityKey = await window.CWI.getPublicKey({
identityKey: true
})
Example Encrypt Function
const ciphertext = await window.CWI.encrypt({
plaintext: Buffer.from('Hello BRCs!'),
protocolID: [0, 'Hello World'],
keyID: '1'
})
Implementation
Implementors of this BRC should follow the current wallet method set in BRC-100, then expose those methods on the window object in a CWI-compatible object where this substrate is used.
