slp-parser is a JavaScript Library for parsing Simple Ledger Protocol (SLP) metadata. TokenType1 and NFT1 tokens are supported. This repo is designed to be easy to port to other languages.
npm install slp-parser
<script src='https://unpkg.com/slp-parser'></script>
This library does not perform any validation of the inputs, dealing solely with parsing the OP_RETURN messages SLP uses to function. If this is not clear, please read the slp-specifications.
NOTES:
- The BigNumber.js library is used to avoid precision issues with numbers having more than 15 significant digits. This can be accessed with
slpParser.BN
.
This library has a single method called parseSLP
which takes either a Buffer or a hex-string and returns an object such as described with the type definitions inside ./lib/index.ts
.
There are additional examples in examples
folder.
const slpParser = require('slp-parser');
const obj = slpParser.parseSLP(Buffer.from('6a04534c500001010747454e455349534c004c004c004c0001004c00080000000000000064', 'hex'));
console.log(obj);
<script>
const slpParser = require('slp-parser');
const obj = slpParser.parseSLP('6a04534c500001010747454e455349534c004c004c004c0001004c00080000000000000064');
console.log(obj);
</script>
Building this project creates browserified versions in the dist
folder.
Running the unit tests require node.js v8.15+.
npm run build
npm run test
slp-parser 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 :)
- tokenid -> tokenId for consistency, additional examples
- Fix reverse tokenid
- Added additional unit tests, fixed bug with child NFTs
- Initial release