Introducing Nimble

A solid bitcoin library is the foundation for any bitcoin app or service, and also for Run. Today we’re pleased to announce nimble - a practical everyday JavaScript library for BSV. Weighing in at just 64kb, you can think of it as smaller, faster, and more modular version of bsv v1 library that you’re probably already using. It works all major browsers and NodeJS 10+ and has a lower-level API for advanced developers too. And it’s open source too! You can start using it today.

Getting started

npm install @runonbitcoin/nimble

or

<script src="https://unpkg.com/@runonbitcoin/nimble@1.0.7"></script>

Let’s see some examples

Create and sign a transaction

1
2
3
4
5
const transaction = new nimble.Transaction()
.from(utxo)
.to(address, amount)
.change(changeAddress)
.sign(privateKey)

Generate new keys and address

1
2
3
const privateKey = nimble.PrivateKey.fromRandom()
const publicKey = privateKey.toPublicKey()
const address = privateKey.toAddress()

Decode transactions scripts

1
2
3
const transaction = nimble.Transaction.fromString(hex)

transaction.outputs[0].script.chunks[0].buf

Hash arbitrary data

1
nimble.functions.sha256(data)

Anything else?

We’re happy that this is the first piece of the Run SDK to be open-sourced with more to come.

Check it out on the github: https://github.com/runonbitcoin/nimble

And we welcome your contributions or ideas for improvement! Thanks.