Git Product home page Git Product logo

slp-parser.js's Introduction

SLP Parser

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

Installation

For node.js

npm install slp-parser

For browser

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

Examples

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.

How to parse

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.

Node.js

const slpParser = require('slp-parser');
const obj = slpParser.parseSLP(Buffer.from('6a04534c500001010747454e455349534c004c004c004c0001004c00080000000000000064', 'hex'));
console.log(obj);

Web

<script>
const slpParser = require('slp-parser');
const obj = slpParser.parseSLP('6a04534c500001010747454e455349534c004c004c004c0001004c00080000000000000064');
console.log(obj);
</script>

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-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 :)

Change Log

0.0.4

  • tokenid -> tokenId for consistency, additional examples

0.0.3

  • Fix reverse tokenid

0.0.2

  • Added additional unit tests, fixed bug with child NFTs

0.0.1

  • Initial release

slp-parser.js's People

Contributors

blockparty-sh avatar

Stargazers

 avatar kristof kaehler avatar Jason Dreyzehner avatar

Watchers

James Cloos avatar James Cramer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.