- Create new file
test.html
with the following single line:
<script src='bcoin.js'></script>
- Bundle bcoin
$ npm install -g bpkg
$ bpkg --browser --standalone --name BCOIN --output /path/adjacent/to/html/file/bcoin.js /git/repo/bcoin/lib/bcoin.js
- Load
test.html
in browser, open JS console, observe:
> new BCOIN.Block()
Block {version: 1, prevBlock: Uint8Array(32), merkleRoot: Uint8Array(32), time: 0, bits: 0, …}
> new BCOIN.Block().inspect()
{hash: "4ddd9f0855d58a375be5a763e5f51ece853d30525fcd9a3e477c2194fedb549f", height: -1, size: 81, virtualSize: 81, date: "1970-01-01T00:00:00Z", …}