Ripple

Ripple JSON API - 我可以在交易時使用多個目的地嗎?

  • May 16, 2018

在 Ripple API 中,

是否有任何 api 可用於拆分付款,我可以在單筆交易中傳遞多個目標地址。

讓我分享程式碼:

const RippleAPI = require('ripple-lib').RippleAPI;

const api = new RippleAPI({
   server: 'wss://s.altnet.rippletest.net:51233' // Public rippled server
});



//Payment API:
const address = 'r4Ct32uDZvL9e5GRbPftAnu8rpCg7aXXXX';
const secret = 'shvtBfNDJ3yf9sqGoc7XUgSTnXXXX';
const instructions = {maxLedgerVersionOffset: 5};
const payment = {
   source: {
       address: address,
       maxAmount: {
           value: '1.01',
           currency: 'XRP'
       }
   },
   destination: [{
       address: 'rn8KqzsH7b8fGZYmbaDXinLb8XffneXXXX',
       amount: {
           value: '1.01',
           currency: 'XRP'
       }
   },
   {
       address: 'rn8KqzsH7b8fGZYmbaDXinLb8XffneXXXX',
       amount: {
           value: '2.01',
           currency: 'XRP'
       }
   }]
};
function quit(message) {
   console.log(message);
   process.exit(0);
}
function fail(message) {
   console.error(message);
   process.exit(1);
}
api.connect().then(() => {
   console.log('Connected...');
   return api.preparePayment(address, payment, instructions).then(prepared => {
       console.log('Payment transaction prepared...');
       const {signedTransaction} = api.sign(prepared.txJSON, secret);
       console.log('Payment transaction signed...');
       api.submit(signedTransaction).then(quit, fail);
   });
}).catch(fail);

目前,我收到錯誤,我在數組中傳遞指定地址。但如果我將作為對象,那麼它會正常工作。但我需要在單筆交易中傳遞多個地址。

你能盡快給出解決方案嗎?

目前沒有…您只能使用單個目標地址

引用自:https://bitcoin.stackexchange.com/questions/72884