Skip to content

Instantly share code, notes, and snippets.

@pinheadmz
Last active March 11, 2019 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pinheadmz/20335a3975dacf839bf8722c51d3ade3 to your computer and use it in GitHub Desktop.
Save pinheadmz/20335a3975dacf839bf8722c51d3ade3 to your computer and use it in GitHub Desktop.
  1. Create new file test.html with the following single line:

<script src='bcoin.js'></script>

  1. 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
  1. 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", …}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment