Run is and always will be easy to learn and easy to use. Lowering developers’ barrier to entry and entrepreneurs’ time to market are obvious wins, and these values influence every design and product decision we make.

With TokenKit, we’re cranking that easiness dial to Fisher Price levels. With just a few lines of code, casual developers and pros alike can mint fungible and non-fungible tokens with minimum fuss and maximum fun.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const MyCoin = await tokenkit.ft.deploy({
metadata: {
name: 'My Coin',
description: 'My example token',
image: 'b://2373632532517983c948df2f32d89ec4a6c64ece1d71698c21b2ad027edfec60',
},
symbol: 'MYC',
decimals: 2,
})

// Mint coins to many recipients
const txid = await tokenkit.ft.mint(MyCoin.origin, [
[100000000, '1DsPKMo8s9F4a22Px5F8RpAQoV1dDQ5HD9'],
[100000000, '1GPe3sjxeDmvXUjP9jaZwnBEunvRLghahi'],
[100000000, '1EtzqQMMaP8xEjv2mzHKrAN3LXrSEtHPAQ'],
...
])

Putting the FUN in fungible tokens

If you’re familiar with Run, you’ll know that our take on tokens are called Jigs. A Jig is in the purest sense a non-fungible token – so when a jig represents fungible tokens, some extra brain power is required. Spending tokens requires additional steps – you need to think about combining and splitting, and it’s just not as simple as we’d like.

With TokenKit, we’re introducing a concept called a JigBox. You can think of a JigBox as, well, a box of Jigs belonging to a given token class. This gives you a really easy way to see yours or a user’s balance of a token, without needing to worry about searching and filtering through a collection of unrelated Jigs. When it comes to spending tokens from a JigBox, the combing and splitting is abstracted away – sending is just one function call.

1
2
3
4
5
6
const box = await tokenkit.ft.getJigBox(origin)

console.log(box.balance)

// Send amount to single recipient - returns txid
await box.send('1FCKGH5tTjSkLgiQEKzoaKzDcBCD5dVHX6', 100000)

The result is an API that feels more analogous to an account based model - UTXOs become one less thing to worry about. It’s way more intuitive and way more fun.

Demystifying the OrderLock

As is customary in BSV land, we are tagging this next section with Soon™️. But don’t be disappointed, you won’t be waiting long for this and believe me, it’s gonna be worth it 👌🔥🔥…

All NFT and fungible tokens created with TokenKit are, out of the box, fully compatible with the RelayX DEX. Not only that, but TokenKit will soon ship with a DEX API for finding, making and taking offers on the DEX.

The DEX is powered by something called the OrderLock - a Bitcoin locking script that can lock a Jig in an “offer”. The Jig can be spent when another party pays the required satoshis to accept the offer, or the original owner makes a cancellation transaction.

It’s pretty clever stuff and has been publicly available for anyone to take advantage of to build alternative UIs or trading bots – yet no one seems to have done so yet. So, we’ve done the hard work for you – we’ve figured out all the nuances and ironed out all the kinks, and wrapped it up in a super simple API to interact with the DEX with zero friction.

1
2
3
4
5
6
7
8
9
10
11
// Make a sell offer from a JigBox (for fungible tokens)
const box = await tokenkit.ft.getJigBox(origin)
const offer = await tokenkit.dex.makeOffer({
jigbox: box,
amount: 5000, // number of tokens to sell
address: '13fDD3U6PdM5VWHwgLDPwZ3itzgU2BRcDW', // purse address to receive payment
satoshis: 100000, // required payment for all offered tokens
})

// Accept an offer - returns txid, resync jigbox to see acquired tokens
await tokenkit.dex.takeOffer(offer.location)

For some frustratingly technical reasons, we’ve had to hold back releasing the DEX features until we ship a version of run-sdk powered by our new Bitcoin library, nimble. But rest assured this is coming down the tracks fast!

Use TokenKit now

TokenKit can be installed now using npm:

1
npm install @runonbitcoin/tokenkit

To get started, checkout out the TokenKit README on GitHub.

Keep your 👀 peeled for the DEX features landing soon!