Advanced jig metadata

Something nice about jigs is that they can carry metadata. Metadata is all the useful information for displaying and describing jigs to users, such as names, images, 3D models, audio, and more. Wallets and exchanges read this information to make better user experiences.

Most of the time people store this media data directly on the BSV blockchain. The standard way to attach media as metadata on jigs is by using B files. B is a simple protocol to upload binary data (files) to the BSV blockchain.

Any B uri can be used as metadata for a jig. For example:

1
2
3
4
5
6
7
8
class Dragon extends Jig {
init (name, imageUri) {
this.name = name
this.metadata = { image: imageUri }
}
}

const aDragon = new Dragon('pepe', 'b://92b00456e0072ad51a97fe6ff31ba59079128529cb5b247eea5588610cb3d493')

But uploading B data is not always easy.

Introducing EasyB

EasyB is a CLI tool and micro library to manage B transactions. EasyB removes all the complexity around building, signing, validating and publishing transactions. The only thing needed to publish files using easy B is a little bit of BSV to fund transactions, and the rest is managed by the library.

EasyB can be used in 2 different ways. As a CLI tool, easy-b is easy to integrate inside bash scripts, deployment pipelines, etc. But EasyB can also be used as a standalone library inside nodejs, which offers tons of flexibility to integrate inside any kind of custom logic. Let’s see an example of both of these usages:

cli

1
2
3
export PURSE_WIF=<my-funded-wif-key>
npx @runonbitcoin/easy-b publish ~/Images/dragon.png
# output: Success! 92b00456e0072ad51a97fe6ff31ba59079128529cb5b247eea5588610cb3d493

And then with the txid:

1
2
// ...
const aDragon = new Dragon('pepe', 'b://92b00456e0072ad51a97fe6ff31ba59079128529cb5b247eea5588610cb3d493')

from nodejs

Or you can directly use it from nodejs. You just need to install it:

1
2
3
4
5
npm i --save @runonbitcoin/easy-b

# or

yarn add @runonbitcoin/easy-b

And then use it:

1
2
3
4
5
6
7
8
9
const { BFile, publish, networks } = require('@runonbitcoin/easy-b') 

const main = async () => {
const bFile = await BFile.fromFilePath('~/Images/dragon.png')
const txid = await publish(bFile, networks.MAINNET, process.env.PURSE_WIF)
const aDragon = new Dragon('pepe', `b://${txid}`)
}

main()

EasyB is already published and ready to be used here. If you found any issue or have suggestions you can publish them as an issue on github.