UNPKG

nerve-sdk-js

Version:
38 lines (28 loc) 1.66 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); }); }; } /** * 创建稳定币Swap交易对 */ var nerve = require('../../index'); // 设置网络环境 nerve.testnet(); // 账户信息 var fromAddress = "TNVTdTSPMcyC8e7jz8f6ngX5yTmK6S8CXEGva"; var pri = ''; var coins = [nerve.swap.token(5, 6), nerve.swap.token(5, 9), nerve.swap.token(5, 7), nerve.swap.token(5, 8)]; var symbol = ''; // LP名称(选填) var remark = 'stable swap create pair remark...'; //调用 test(); function test() { return _test.apply(this, arguments); } function _test() { _test = _asyncToGenerator(function* () { var tx = yield nerve.swap.stableSwapCreatePair(fromAddress, coins, symbol, 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); }