A Rust/WASM Library to interact with Bitcoin SV

npm i bsv-wasm-bundler --save


A Rust/WASM Library to interact with Bitcoin SV


NodeJS 14.6+:
npm i bsv-wasm --save

npm i bsv-wasm-web --save

npm i bsv-wasm-bundler --save




Note: Rust and JS/TS method names and structs are the same

  • Eg. Derive private key from XPriv and log out P2PKH String ExtendedPrivateKey.fromWIF('LMyWif...').toPrivateKey().toPublicKey().toAddress().toString()


  • Hash (SHA256, SHA256d, SHA1, RIPEMD160, Hash160, SHA512)
  • KDF (PBKDF2)
  • Encryption (AES-CBC, AES-CTR)
  • ECDSA (Private Key, Public Key, Signatures)
  • Transaction (Building, Serialising, Deserialising)
  • Script (Serialising, Deserialising)
  • Script Matching (ScriptTemplate)
  • Addresses (P2PKH)
  • Sighash Support
  • Extended Private Keys and Child Derivation (BIP32, BIP42)
  • Testnet support


  • Isomorphic Package for JS
  • Write documentation (Inline on functions and structs)

Will not do:

  • Mnemonics


  • Brenton Gunning (rust-sv)
  • Moneybutton Team (bsv.js)
  • Bitping Team
  • Bitcoin SV Wiki

Collection of the latest Issues



Comment Icon0

The TxIn constructor requires a script, however when a transaction input is first created, its script is typically not yet known. Therefore providing a script should be optional.

How I'm currently adding an input

How I'd like to add an input



Comment Icon0
  • Document all Structs
  • Document all functions
  • JSDoc for all documentation


Comment Icon1

Quick wins:

  • Replace all the anyhow::Error properties in Error enums either with an enum or a simple type like &str

Find the latest versions by id

1.3.1 - May 11, 2022

  • Fixes init function naming in bsv-wasm-web

Full Changelog:

1.3.0 - May 11, 2022

What's Changed

Full Changelog:

1.3.0-beta.7 - Mar 18, 2022

  • Fixed pushdata byte length prefixes on PUSHDATA1

1.3.0-beta.6 - Mar 08, 2022

  • Fixed HashCache issues for SIGHASH_NONE/ANYONECANPAY
  • Fixed K signing endianness

1.3.0-beta.5 - Mar 06, 2022

Added custom K signing and private key recovery from known signature + K.

1.3.0-beta.4 - Jan 06, 2022

1.3.0-beta.3 - Dec 07, 2021

1.3.0-beta.2 - Dec 07, 2021

What's Changed

Full Changelog:

1.3.0-beta.1 - Dec 06, 2021

What's Changed

Full Changelog:

1.2.3 - Nov 30, 2021

  • (Rust only) Remove WASM dependencies from non WASM targets.
  • Added new methods to Script
    • encode_pushdata (Generates a Script encoded OP_PUSHDATA buffer from the provided data)
    • get_pushdata_bytes (Generates a OP_PUSHDATA varint prefix buffer based on a provided length)

1.2.2 - Nov 28, 2021

Remove wee_alloc global allocator which was causing memory leaks.

1.2.1 - Nov 12, 2021

Fix some annoying WASM warnings when importing into Webpack

1.2.0 - Nov 12, 2021


  • Tx.getOutpoints() - Returns a Uint8Array[] with all of the outpoints from the TxIns on the Transaction
  • No longer requires Rust nightly to build
  • Extended Transaction Format (TX+)
    • Adds optional fields to TxIn

      • satoshis: Option<u64>
        • txin.getSatoshis()
        • Satoshis field on TxIn makes it easy to do calculations and signing for transactions that get passed around without having to consult a UTXO store. If you serialise the Tx to JSON or toCompactBytes() (CBOR), it adds the extra fields when available.
      • unlocking_script: Option<Script>
        • txin.getUnlockingScriptBytes()
        • Unlocking Script field on TxIn allows you to pass around partially signed transactions without having to continually change the script sig. This field will automatically be prepended to the script_sig when calling .toBytes() or .toHex() to enable a convenient way to export the transaction to Bitcoin network format.
    • Adds convenience methods for querying Total Satoshis in and Total Satoshis out

      • Tx.satoshisIn() - Returns the total amount of satoshis in the Inputs. If any of the inputs have no specified satoshis, method returns null
      • Tx.satoshisOut() - Returns the total amount of satoshis in the Outputs.
    • Adds ability to match specific TxIns and TxOuts based on a Match Criteria

      • Tx.matchInput() - Returns index of the first input that matches the given criteria
      • Tx.matchOutput() - Returns index of the first output that matches the given criteria
      • Tx.matchInputs() - Returns all indices of inputs that match the given criteria
      • Tx.matchOutputs() - Returns all indices of outputs that match the given criteria

Breaking Changes:

  • Change all references of getPublicKey to toPublicKey
  • ECIESCiphertext: Change extractCiphertext to getCiphertext
  • ECIESCiphertext: Change extractHMAC to getHMAC

Bug Fixes:

  • Fix Safari 14 not supporting BigUint64Array
  • Fix OP_PUSHDATA trying to read more bytes than necessary

1.2.0-beta.4 - Sep 06, 2021

Removes some unnecessary dependencies

1.2.0-beta.3 - Aug 05, 2021

Skipping Beta 2 as a previous deployment poisioned that version.

1.2.0-beta.1 - Jul 26, 2021

1.1.2 - Jul 17, 2021

Breaking changes:

  • P2PKHAddress.fromP2PKHString -> fromString
  • P2PKHAddress.toAddressString -> toString

1.1.1 - Jul 15, 2021

Bug fixes:

  • Fix P2PKH Unlocking Script Parameters to take SighashSignature
  • More tests, fix bug when deriving address and pubkey from priv, not honouring compression

1.1.0 - Jul 13, 2021


  • Support for Recoverable Public Keys from Signatures
    • Signature.getPublicKey()
  • Bitcoin Signed Message support
    • BSM.signMessage(private_key, message)
  • Ability to verify if a signature was signed by a P2PKH address
    • Address.verifyBitcoinMessage(message, signature)
    • BSM.verifyMessage(message, signature, address)
  • Added functions to verify Signatures that don't fail
    • Address.isValidBitcoinMessage(message, signature)
    • BSM.isValidMessage(message, signature, address)
  • Added ECDSA low level digital signature primitives
  • Added toUnlockingScript and toLockingScript to P2PKHAddress
    • Address.toUnlockingScript(pub_key, signature)
    • Address.toUnlockingScript()
  • Function Chaining from ExtendedPrivateKey all the way to P2PKHAddress
    • ExtendedPrivateKey.fromWIF('LMyWif...').getPrivateKey().getPublicKey().toAddress().toString()
  • Shrunk bundle by 60kb

Breaking Changes:

  • No longer need to pass is_compact parameter to various public key/private key functions. Compact is inferred from the Point.
  • Signature.fromHexDER() now takes an extra "is recoverable" parameter - this is subject to change in the future.
  • Signature.verify has been changed to Signature.verifyMessage

Information - Updated Jun 03, 2022

Stars: 49
Forks: 11
Issues: 8

Repositories & Extras

Rust / Wasm client web app framework

Pull requests which improve test coverage are also very welcome

Rust / Wasm client web app framework

WASM / Rust / D3 example

Fetch data with Rust + WASM and show it with JS + D3

WASM / Rust / D3 example


A template for kick starting a Rust and WebAssembly project using Tutorial


rust wasm worker hello world

Built using the template at which

rust wasm worker hello world

Rust WASM Web Worker Examples

This repository contains four different examples of using web workers in conjunction with WASM in

Rust WASM Web Worker Examples


WebAssembly でマンデルブロ集合を描きます



Conway's Game of Life with Rust and Web Assembly



A fast and efficient Conway's Game of Life simulation made with Rust &amp; compiled for the web

Facebook Instagram Twitter GitHub Dribbble