SLP Metadata Maker
npm install slp-mdm
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.
- The BigNumber.js library is used to avoid precision issues with numbers having more than 15 significant digits. This can be accessed with
- 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.
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 );
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) );
Transfer tokens to new UTXOs. You can also use
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
Running the unit tests require node.js v8.15+.
npm run build
npm run test
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 :)
- Allows for Buffer for documentHash and tokenIdHex
- Perform strictNullChecks
- Make mint_baton_vout nullable
- Improved some error messages
- Fixed README
- Initial release