如何使用Bitgo发送XRP令牌

时间:2018-07-19 06:42:55

标签: node.js

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'

1 个答案:

答案 0 :(得分:0)

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