Guides

The browser wallet connects to the user's BSV wallet extension (such as MetaNet Client) and provides a full-featured API for blockchain operations.

Connecting

import { createWallet } from '@bsv/simple/browser'

const wallet = await createWallet()

This prompts the user to approve the connection. Once approved, the wallet is ready to use.

With Custom Defaults

const wallet = await createWallet({
  network: 'main',
  tokenBasket: 'my-tokens',        // default basket for tokens
  messageBoxHost: 'https://messagebox.babbage.systems',
  registryUrl: '/api/identity-registry'
})

Any default can be overridden per-method call.

Wallet Info

// Identity key (compressed public key, 66 hex chars)
const key = wallet.getIdentityKey()
// '02a1b2c3d4...'

// P2PKH address
const address = wallet.getAddress()
// '1A2b3C4d5E...'

// Status object
const status = wallet.getStatus()
// { isConnected: true, identityKey: '02a1b2...', network: 'main' }

// Full info object
const info = wallet.getWalletInfo()
// { identityKey, address, network, isConnected }

Key Derivation

Derive public keys for specific protocols and counterparties.

Generic Derivation

BRC-29 Payment Key

A convenience method for deriving BRC-29 payment keys:

This uses protocol ID [2, '3241645161d8'] internally.

Accessing the Underlying Client

For advanced operations that aren't covered by the simple API:

Default Configuration

Setting
Default
Description

network

'main'

Network to operate on

description

'BSV-Simplify transaction'

Default transaction description

outputDescription

'BSV-Simplify output'

Default output description

tokenBasket

'tokens'

Default basket for token operations

tokenProtocolID

[0, 'token']

Default PushDrop protocol ID

tokenKeyID

'1'

Default PushDrop key ID

messageBoxHost

'https://messagebox.babbage.systems'

MessageBox server URL

registryUrl

undefined

Identity registry API URL

Type Reference

Last updated