UNPKG

etkframework

Version:

First test release of Etk over colored coins SDK

66 lines (58 loc) 2.38 kB
// #!/usr/local/bin/node --harmony /** * Etk Operations library. * A wrapper using Colored Coins SDK to create standard token functions that can * be used to build EarthShares. * Core Developer(s): @codecakes Akul Mathur akul at earthbenign dot com * Maintainer(s): * @codecakes Akul Mathur akul at earthbenign dot com */ "use strict"; const path = require("path"), settingsCreate = require('./opHelper/settingsHelper').settingsCreate, //minified client side version of the the main colu library Colu = require("colu"), transfer = function transfer (network, apiKey, privateSeed, asset, cbTxn) { /** Transfer Function * Sends an asset from one address to one or more other addresses * Returns the TXN JSON response *@params: * privateSeed: the Seed Key * asset: the asset. This is what defines the issue and send attributes * Usually like: * var asset = { amount: 1, divisibility:3 reissueable: true, issuer: <Issuer Name>, description: <Some description> from: fromAddress, to: [{ address: toAddress, assetId: assetId, amount: 1}] } if more than one address is specified in the to section, transfers to multiple parties with their respective amount provided in the amount field. * cbTxn: Callback to process the TXN JSON response; */ const //initialize colu object with settings colu = new Colu(settingsCreate(network, apiKey, privateSeed)); colu.on('connect', function () { colu.sendAsset(asset, function (err, body) { let res = {}; if (err) { res.err = err; res.type = "error"; } else { res.body = body; res.type = "message"; } cbTxn(res); }); }); colu.init(); }; exports.transfer = transfer;