首页 > 解决方案 > 如何使用 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”

标签: node.js

解决方案


您必须将金额修改为有效字符串。bitgo'8000.0'不接受金额,您必须删除字符串的小数部分。所以有效金额是'8000'


推荐阅读