UNPKG

nerve-sdk-js

Version:
36 lines (26 loc) 1.58 kB
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } /** * 质押farm */ var nerve = require('../../index'); // 设置网络环境 nerve.testnet(); // 账户信息 var fromAddress = "TNVTdTSPRnXkDiagy7enti1KL75NU5AxC9sQA"; var pri = ''; var remark = 'farm update remark...'; //调用 test(); function test() { return _test.apply(this, arguments); } function _test() { _test = _asyncToGenerator(function* () { var tx = yield nerve.swap.farmUpdate(fromAddress, "80f375ffb94ac8058647e7d6eda6ef1463433d525de03f4e644efea334cd0bc7", 0, nerve.swap.token(5, 15), 0, 100000000, 1000000, 5, "TNVT", remark); console.log('hash: ' + tx.hash); console.log('hex: ' + tx.hex); // 签名交易 var signedTx = nerve.appendSignature(tx.hex, pri); console.log('signedTx hash: ' + signedTx.data.hash); console.log('signedTx hex: ' + signedTx.data.hex); // 广播交易 nerve.broadcastTx(signedTx.data.hex); }); return _test.apply(this, arguments); }