Technical Spec

The BitGen technical spec with working examples and code

Working Examples

Working example using local references: https://toniq-labs.github.io/bitgen-example/

Working example Github repo: https://github.com/Toniq-Labs/bitgen-example

Code Examples

Below is a fully functional version of each file type (final testing on Bitcoin mainnet in progress)

  1. The Renderer JS

  2. The Collection JS

  3. The Collection JSON

  4. The Asset Layer IMAGES

  5. The Inscription HTML

  6. The Provenance JSON

  7. Content Security Policy

  8. Rendering IFrames

Renderer JS

Collection JS

Collection JSON

Asset Layer IMAGES

These inscriptions are simply inscribing each entire image file as its own inscription as bytes.

Inscription HTML

Provenance JSON

Content Security Policy

In order to view BitGen ordinal images on your website, we recommend the following CSP header:

In addition the the CSP listed, you should also include the domain (or sub-domain) where you are hosting your iframe code (see IFrames section below on why this is important).

WebKit browsers (desktop Safari and all iOS browsers) have stricter CSP parsing compared to other browsers, so make sure to test whatever CSP headers you come up with on those browsers. (The above recommended header value has already been tested on WebKit browsers).

IFrames

To display HTML ordinals on your website (such as those generated by the BitGen standard) you must load the inscription inside an iframe. For security purposes, make sure to host your iframe code on a different domain (or sub-domain) than your frontend to prevent inscription code from hijacking your website.

You might think that sandboxing the iframes on your frontend and whitelisting certain paths on your domain is enough, but in order to get inscriptions working on Safari/iPhone (webkit browsers) you have to allow scripts and cross origin on your iframes, which essentially removes any of the protections of sandboxing (a script could just remove sandboxing and access the parent window local storage or cookies). This is why we put our iframe code on a separate domain from our main website (it acts as sandboxing) without having to specify sandboxing in our iframes or having to whitelist certain paths.

Combine this with iframe sizing difficulties, and it can make displaying ordinals a daunting task. To help, we at Bioniq have created toniq-nft-frame to smooth out the process. Check it out here.

Last updated