npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

slp-mdm

v0.0.7

Published

Create Simple Ledger Protocol OP_RETURN data segments with ease!

Downloads

7,209

Readme

SLP Metadata Maker

slp-mdm is a JavaScript Library for building Simple Ledger Protocol (SLP) metadata for use in Bitcoin transactions. GENESIS, MINT, and SEND token functions are supported for TokenType1 and NFT1 tokens. This repo is designed to be easy to port to other languages, and should be combined with a transaction building library such as bitcore-lib-cash, and a validation library such as slp-validate.

NPM

Installation

For node.js

npm install slp-mdm

For browser

<script src='https://unpkg.com/slp-mdm'></script>

Examples

Software utilizing this library will want to validate the transactions they create do not burn any tokens. This library does not perform any validation of the inputs or output amounts, dealing solely with creating the OP_RETURN messages SLP needs to function. If this is not clear, please read the slp-specifications as it is possible to burn tokens by using this library incorrectly.

NOTES:

  • The BigNumber.js library is used to avoid precision issues with numbers having more than 15 significant digits. This can be accessed with slpMdm.BN.
  • All slp-mdm methods require token quantities to be expressed in the smallest possible unit of account for the token (i.e., token satoshis). This requires the token's precision to be used to calculate the quantity. For example, token having a decimal precision of 9 sending an amount of 1.01 tokens would need to first calculate the sending amount using 1.01 x 10^9 => 1010000000.

GENESIS

Create a new normal token. You can also use NFT1.Group.genesis for this. NFT1.Child.genesis has slightly different signature and is described below.

const slpMdm = require('slp-mdm');
const buf = slpMdm.TokenType1.genesis(
  'TOK',                                                              // symbol
  'token_name',                                                       // name
  'https://fountainhead.cash/document.pdf',                           // document_uri
  'f8bf41177a5f5e808a7ccb648b51080b031f15ca8018d91a576263d6cc626eb6', // document_hash
  5,                                                                  // decimals
  null,                                                               // mint_baton_vout
  new slpMdm.BN("1000")                                               // quantity (needs to be BigNumber)
);

NFT1 Child Genesis

NFT1-child tokens have quantity set to 1, no baton vout (i.e. future minting impossible), and have 0 decimal places. Because of these differences, the signature for this method excludes these parameters.

const slpMdm = require('slp-mdm');
const buf = slpMdm.NFT1.Child.genesis(
  'IVAN',                                                             // symbol
  'gorilla'                                                           // name
  'https://fountainhead.cash/document.pdf',                           // document_uri
  'f8bf41177a5f5e808a7ccb648b51080b031f15ca8018d91a576263d6cc626eb6'  // document_hash
);

MINT

Mints additional tokens. You can also use NFT1.Group.mint, NFT1.Child does not support minting additional tokens.

const slpMdm = require('slp-mdm');
const buf = slpMdm.TokenType1.mint(
  'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', // token_id
  null,                                                               // mint_baton_vout 
  new slpMdm.BN("500")                                                // quantity (needs to be BigNumber)
);

SEND

Transfer tokens to new UTXOs. You can also use NFT1.Group.send, or NFT1.Child.send for this.

const slpMdm = require('slp-mdm');
const buf = slpMdm.TokenType1.send(
  'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', // token_id
  [                                                                   // slp_amounts to send
    new slpMdm.BN("100"), 
    new slpMdm.BN("200"), 
    new slpMdm.BN("300"), 
  ]
);

Building & Testing

Building this project creates browserified versions in the dist folder.

Requirements

Running the unit tests require node.js v8.15+.

Build

npm run build

Test

npm run test

Porting

slp-mdm was designed to be very easy to port to other languages. If you are working on a port to another language please open an issue on this repo so we can link to your port or help with any questions. Make sure to utilize the unit-tests :)

Change Log

0.0.6

  • Allows for Buffer for documentHash and tokenIdHex

0.0.5

  • Perform strictNullChecks

0.0.4

  • Make mint_baton_vout nullable

0.0.3

  • Improved some error messages

0.0.2

  • Fixed README

0.0.1

  • Initial release