# slp-parser

> Parse Simple Ledger Protocol OP_RETURN data segments with ease!

Latest version **0.0.4** (published 2020-04-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install slp-parser
pnpm add slp-parser
yarn add slp-parser
bun add slp-parser
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2020-04-12 |
| First published | 2020-04-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 708.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | blockparty-sh |
| Maintainers | fountainhead.cash |
| Keywords | SLP, simple, ledger, protocol, metadata, op_return, parser |

## Links

- npm: https://www.npmjs.com/package/slp-parser
- Repository: https://github.com/simpleledger/slp-parser.js
- Homepage: https://github.com/simpleledger/slp-parser.js#readme
- Issues: https://github.com/simpleledger/slp-parser.js/issues
- npm.io page: https://npm.io/package/slp-parser

## Dependencies (1)

- [bignumber.js](https://npm.io/package/bignumber.js.md) ^9.0.0

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.0.4 (latest) — 2020-04-12
- 0.0.3 — 2020-04-05
- 0.0.2 — 2020-04-05
- 0.0.1 — 2020-04-05

## README

# SLP Parser

slp-parser is a JavaScript Library for parsing [Simple Ledger Protocol (SLP)](https://github.com/simpleledger/slp-specifications) metadata. TokenType1 and NFT1 tokens are supported. This repo is designed to be easy to port to other languages.

[![NPM](https://nodei.co/npm/slp-parser.png)](https://nodei.co/npm/slp-parser/)


# Installation

#### For node.js
```bash
npm install slp-parser
```

#### For browser
```html
<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](https://github.com/simpleledger/slp-specifications).

NOTES: 

* The [BigNumber.js library](https://github.com/MikeMcl/bignumber.js) 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
```js
const slpParser = require('slp-parser');
const obj = slpParser.parseSLP(Buffer.from('6a04534c500001010747454e455349534c004c004c004c0001004c00080000000000000064', 'hex'));
console.log(obj);
```

### Web

```html
<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

---
_Source: https://npm.io/package/slp-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
