etkframework
Version:
First test release of Etk over colored coins SDK
88 lines (73 loc) • 3.07 kB
JavaScript
// #!/usr/local/bin/node --harmony
/**
* Etk Operations library.
* A wrapper using Colored Coins SDK to issue tokens.
*
* Copyright (C) 2015 Akul Mathur
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Parts of the software are provided under separate licenses, as follows:
"colu-nodejs" SDK is under the MIT License
"pbkdf2-sha256" is under the BSD License
"bip38" is under the MIT License
"scryptsy" is under the MIT License
"coinstring" is under the MIT License
*
* Core Developer(s): @codecakes Akul Mathur akul at earthbenign dot com
* Maintainer(s):
* @codecakes Akul Mathur akul at earthbenign dot com
*/
;
const
path = require("path"),
settingsCreate = require('./opHelper/settingsHelper').settingsCreate,
//minified client side version of the the main colu library
Colu = require("colu"),
issueToken = function issueToken (privateSeed, network, apiKey, asset, cbTokenBody) {
let colu = new Colu(settingsCreate(network, apiKey, privateSeed));
colu.on('connect', function () {
colu.issueAsset(asset, function (err, body) {
let res = {};
if (!!err) {
res.err = err;
res.type = 'error';
} else {
res.body = body;
res.type = 'message';
}
// console.log(res);
cbTokenBody( res );
});
});
colu.init();
};
exports.issueToken = issueToken;
// debugging purpose only
// let
// apiKey = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJha3VybnlhQGdtYWlsLmNvbSIsImV4cCI6IjIwMTUtMDgtMzBUMTc6MzI6NTguODEyWiIsInR5cGUiOiJhcGlfa2V5In0.MrEGduJboIZaOd6u-7Pv3ul8sU0X-HaZC1EDNdEiBkU",
// seed = '19f9181ac8f0a7a9e73e83bffb84d4eef911ae902a8502581b0e13cea3b03e25',
// address = 'n3TBcnfh25a3e7JYFXxDDFir9fXLfmWbwF',
// network = 'testnet',
// asset = {
// "amount": "100000",
// "issueAddress": address,
// "divisibility": "3",
// "reissueable": "false",
// "metadata": {
// "assetName": "TestCoins 4",
// "issuer": "Etk",
// "description": "Etk TestCoins 4"
// }
// };
// issueToken(seed, network, apiKey, asset, function (assetBody) {
// console.log(assetBody);
// process.exit();
// });