Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cc-burn-payment-encoder

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cc-burn-payment-encoder

The encoding/decoding functions for the colored-coins burn payment object scheme

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-25%
Maintainers
1
Weekly downloads
 
Created
Source

Burn-Payment-Encoder

Build Status Coverage Status npm version
Slack Status

Standard - JavaScript Style Guide

Payment-Encoder provides the encode/decode functions between a Colored Coins burn-transaction payment Object to buffer

Installation

$ npm install cc-burn-payment-encoder

Encode

Params:

paymentObject - A standard Colored Coins payment object with the following properties:

{
  // Skip input after reading asset
  skip: "Boolean"

  // Range or fixed value output (valid only if burn is false or undefined)
  range: "Boolean"

  // percent or fixed amount
  percent: "Boolean"

  // Output to send asset to - max value is 30 if range is false and 8191 if true (valid only if burn is false or undefined)
  output: "Number"

  // Total amount of units to send
  amount: "Number"

  // Should this payment be interpreted as an execution of "burn" (valid only if output value and range are undefined)
  burn: "Boolean"
}

Returns a new Buffer holding the encoded payment.

Example:
var paymentEncode = require('cc-burn-payment-encoder')
var paymentObject = {
    skip: false,
    range: false,
    percent: true,
    output: 1,
    amount: 321321321
}

var code = paymentEncode.encode(paymentObject)

console.log(code) // Will print: <Buffer 21 80 99 37 cb 48>

Alternatively, you can encode a "burn" payment:

var paymentObject = {
    skip: false,
    percent: false,
    amount: 13,
    burn: true
}

var code = paymentEncode.encode(paymentObject)

console.log(code) // Will print: <Buffer 1f 0d>

Decode

Params:

  • consume - takes a consumable buffer (You can use buffer-consumer like in the example to create one)

Returns a Colored Coins payment Object

Example:
var paymentEncode = require('cc-burn-payment-encoder')
var consumer = require('buffer-consumer')

var decode = paymentEncode.decode(consumer(code))
var codeBuffer = new Buffer([0x82,0x76,0x0e,0x1b,0x48])

console.log(paymentEncode.decode(consumer(codeBuffer)))
// Will print:
// {
//  skip: false,
//  range: false,
//  percent: true,
//  output: 1,
//  amount: 321321321
//  }

Testing

In order to test you need to install mocha globaly on your machine

$ cd /"module-path"/cc-burn-payment-encoder
$ mocha

License

Apache-2.0

Keywords

FAQs

Package last updated on 13 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc