@bitcoin-corporation/brc100-wallet
v0.1.0
Published
Drop-in browser client for the BRC-100 Google Wallet API — sign in with Google, get a Bitcoin SV wallet.
Maintainers
Readme
@bitcoin-corporation/brc100-wallet
Drop-in browser client for the BRC-100 Google Wallet API. Sign in with Google → get a Bitcoin SV wallet, in about five lines.
Maintained by The Bitcoin Corporation Ltd.
Add it to your site
Option 1 — script tag (no build step)
<div id="signin"></div>
<script src="https://YOUR-API-HOST/sdk/brc100-wallet.js"></script>
<script>
const wallet = new BRC100Wallet({ apiBase: 'https://YOUR-API-HOST' })
wallet.mountSignIn('#signin', {
onReady: async (s) => {
console.log('wallet:', s.wallet.identityKey, s.wallet.address)
console.log('balance:', (await wallet.balance()).satoshis, 'sat')
},
})
</script>That's it. mountSignIn shows the real Google button if the API has a Client ID
configured, or a dev-login form otherwise.
You can also load it from a CDN once published:
<script src="https://cdn.jsdelivr.net/npm/@bitcoin-corporation/brc100-wallet"></script>Option 2 — npm
npm install @bitcoin-corporation/brc100-walletimport BRC100Wallet from '@bitcoin-corporation/brc100-wallet'
const wallet = new BRC100Wallet({ apiBase: 'https://YOUR-API-HOST' })
await wallet.mountSignIn('#signin', { onReady: (s) => console.log(s.wallet) })API
const wallet = new BRC100Wallet({ apiBase, storageKey?, autoResume?, storage? })
// auth
wallet.mountSignIn(target, { onReady, onError, button })
await wallet.signInWithGoogleCredential(idToken) // if you render your own button
await wallet.devSignIn('user-id') // dev only
wallet.isSignedIn()
wallet.signOut()
// wallet
await wallet.getWallet() // { network, identityKey, address }
await wallet.balance() // { satoshis, outputs, basket }
await wallet.outputs({ limit }) // UTXOs
await wallet.actions({ limit }) // history
await wallet.pay({ to, satoshis, description })
await wallet.sign({ data })
await wallet.encrypt({ plaintext })
await wallet.decrypt({ ciphertext })
await wallet.exportKey() // migrate to self-custodyThe session token is persisted (localStorage by default) so users stay signed in.
Publishing (maintainers)
The package is publish-ready (npm pack --dry-run ships 5 files, ~5 kB).
# one-time: create the @bitcoin-corporation org on npmjs.com, then:
npm login
cd sdk
npm publish # publishConfig.access is already "public"Notes:
- The
@bitcoin-corporationscope must exist as an npm org you belong to. - Bump
versioninpackage.jsonbefore each publish. - After publishing, the CDN URL works automatically:
https://cdn.jsdelivr.net/npm/@bitcoin-corporation/brc100-wallet
License
MIT © The Bitcoin Corporation Ltd
