node.js - 如何使用 bitgo 发送 xrp 令牌
问题描述
const BitGoJS = require(__dirname + '/BitGoJS/src/index.js');
const bitgo = new BitGoJS.BitGo({ env: 'test' });
const Promise = require('bluebird');
const coin = 'txrp';
const basecoin = bitgo.coin(coin);
// TODO: set your access token here
const accessToken = 'xxxxxxxxxx';
const walletId = 'xxxxxxxxxx';
// TODO: set your passphrase here
const walletPassphrase = 'xxxxxxxxxxxx';
Promise.coroutine(function *()
{
bitgo.authenticateWithAccessToken({ accessToken: accessToken });
bitgo.unlock({ otp: '0000000' }).then(function(unlockResponse) {
});
let user_walletId = 'xxxx';
const walletInstance = yield basecoin.wallets().get({ id: walletId });
const wallet = yield basecoin.wallets().get({ id: user_walletId });
const newReceiveAddress1 = wallet.receiveAddress();
console.log('receiveAddress is :'+newReceiveAddress1);
console.log('Balance is: ' + (walletInstance.balance() / 1e8).toFixed(4));
const transaction = yield walletInstance.sendMany
({
recipients: [
{
amount: '0.1' * 1e8,
address: newReceiveAddress1
},
],
walletPassphrase: walletPassphrase
});
const explanation = basecoin.explainTransaction({ txHex: transaction.tx });
console.log(transaction.tx);
})();
我无法发送 xrp 令牌。在未处理的拒绝错误下方显示 错误:无法读取未定义 requestId=cjjs6t6242xd1p9rx1h5u9lch 的属性“nonNumericString”
解决方案
您必须将金额修改为有效字符串。bitgo'8000.0'
不接受金额,您必须删除字符串的小数部分。所以有效金额是'8000'
。
推荐阅读
- javascript - 如何创建动态列名推送存储在动态变量中的数据
- angular - 如何在 Angular 6 UI 测试中检查组件是否已显示 (*ngIf)
- ios - 是否建议从本机 iOS 应用程序中的设置更改应用程序语言?
- angular - 在 Edge 浏览器上获取 PDF bypassSecurityTrustResourceUrl 的访问被拒绝
- mysql - 将存储为行的名称值对转换为列
- python - 使用 for 循环遍历函数
- android - 是否可以编写视图包装器?
- dependency-injection - Dagger 2 多个存储库
- php - 如何分离用户/管理页面?
- android - 如何以编程方式获取 android 8.1 及更高版本中的蓝牙 mac 地址?