npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cc-transaction-builder

v0.1.7

Published

High-level abstraction for building ColoredCoins transactions

Downloads

8

Readme

cc-transaction-builder

Build Status NPM version Slack Channel

js-standard-style

ColoredCoins Transaction Builder. This module is a high-level abstraction for building transactions for issuing and transferring digital assets using the ColoredCoins protocol.

Note

This repository is a work in progress.

Installation

npm install cc-transaction-builder

Usage

var ColoredCoinsBuilder = require('cc-transaction-builder')
var ccb = new ColoredCoinsBuilder()
var result = ccb.buildsIssueTransaction({
  utxos: [{
    txid: 'b757c9f200c8ccd937ad493b2d499364640c0e2bfc62f99ef9aec635b7ff3474',
    index: 1,
    value: 598595600,
    scriptPubKey: {
      addresses: ['mrS8spZSamejRTW2HG9xshY4pZqhB1BfLY'],
      hex: '76a91477c0232b1c5c77f90754c9a400b825547cc30ebd88ac'
    }
  }],
  issueAddress: 'mrS8spZSamejRTW2HG9xshY4pZqhB1BfLY',
  amount: 3600,
  fee: 5000,
  divisibility: 2
})
console.log(result)

will print:

{ txHex: '01000000017434ffb735c6aef99ef962fc2b0e0c646493492d3b49ad37d9ccc800f2c957b70100000000ffffffff020000000000000000096a074343020522425088c4ad23000000001976a91477c0232b1c5c77f90754c9a400b825547cc30ebd88ac00000000',
  multisigOutputs: [],
  coloredOutputIndexes: [ 1 ],
  assetId: 'La5YH3tri7HbdzTUfeoiZWm8Dv39jJzgKb53JT' }

API

builder = ColoredCoinsBuilder([properties])

Create a new ColoredCoinsBuilder instance.

If properties is specified, then the default properties will be overridden.

{
  network: String,              // Which blockchain network should be used ('testnet' or 'mainnet', default='mainnet')
  defaultFee: Number,           // Transaction miner fee, fixed (default=null)
  defaultFeePerKb: Number,      // Transaction miner fee, per Kb (default=null)
  mindustvalue: Number,         // Minimum value to put in each output, in satoshi (except for OP_RETURN, default=600)
  mindustvaluemultisig: Number  // Minimum value to put in Multisig output, in satoshi (default=700)
}

Note: only one of defaultFee and defaultFeePerKb can provided. If none of them is provided, fee will be mandatory in each API call.

builder.buildIssueTransaction(args)

Build an issuance transaction.

args is a JSON of the format:

  • utxos Object[], array of unspent transaction outputs, required. Each consists of:
    • txid String, transaction ID (hex string of length 64).
    • index Number, UTXO index in its transaction.
    • value Number, value of the UTXO, in satoshi.
    • scriptPubKey Object, cosnists of:
      • addresses String[], array of addresses the output is directed to.
      • hex String, the UTXO's locking script hex.
  • issueAddress String, the Base58Check Bitcoin (or testnet) address which issues the asset, required.
  • amount Number, amount of units of the asset to issue, required.
  • fee Number, transaction miner fee in satoshi, required (unless constructed with one of defaultFee and defaultFeePerKb.
  • divisibility Number, how small is the smallest subdivision of the asset, calculated as 10^(-divisibility) (default=0).
  • lockStatus Boolean, is the issued asset locked (can't be reissued) or unlocked (default=true).
  • transfer Object[], array of transfer objects, each consists of:
    • amount Number, amount of units of the asset to transfer.
    • address String, address to send the assets to.
  • flags Object, consists of:
    • injectPreviousOutput Boolean, if true each input script will be its previous output script (default=false).
    • splitChange Boolean, split colored change and finance (BTC) change into 2 different outputs (default=false).
  • torrentHash String, hex string of length 40 (result of metadata's torrent SHA1).
  • sha2 String, hex string of length 64 (result of metadata SHA2).

On success, returns JSON which consists of:

  • txHex String, the result unsigned transaction hex.
  • assetId String, asset ID of the newly created asset.
  • multisigOutputs Number[], Array of indexes of the transaction multisig outputs.
  • coloredOutputIndexes Number[], Array of indexes of the transaction colored outputs (carrying assets).
  • receivingAddresses String[], Array of addresses which receive the assets.

On failure, may throw an Error.

The description of the 2 following functions will be expanded in the future:

builder.buildSendTransaction(args)

args is a JSON of the format:

  • utxos
    • txid
    • index
    • value
    • scriptPubKey
      • addresses
      • hex
    • assets
      • assetId
      • amount
  • to
    • address
    • amount
    • assetId
  • fee

builder.buildIssueTransaction(args)

args is a JSON of the format:

  • utxos
    • txid
    • index
    • value
    • scriptPubKey
      • addresses
      • hex
    • assets
      • assetId
      • amount
  • burn
    • amount
    • assetId
  • fee