Skip to main content


draft, subject to change

This document describes an interface for communicating with a web browser wallet.

The main focus is on standardizing a method of serializing named parameters

The interface for communicating with a wallet via a secure channel, using an injected JavaScript global object.

The following methods are provided via window.btc or globalThis.btc:

  • request(method: string, params?: {}): Promise<any>
  • listen(event: string, callback: (r) => void, params?: {})

In a web environment, you can use window. The environment-agnostic global variable is globalThis.

request — Request interface


import '@btckit/types';

const address = await window.btc.request('getAddresses', {
account: 0,
change: false,
index: 0,

listen — Event listener interface


import '@btckit/types';

window.btc.listen('networkChanged', network => {
console.log('Network switched in wallet', network);

Wallets can decide on how handle unimplemented methods (or make it configurable to the user). E.g. an unimplemented method could throw an error, or return an error object, or be "dropped" and stuck indefinitely.

Open Questions

  • Should the window.btc returned Promises already detect errors in the response and reject the Promise with the error code? Should fields like id and jsonrpc be part of the Promise response or just the result/error?