In Ripple API,
Is there any apis available to split payment which I can pass more than one destination address in single transaction.
Let me share code:
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);
Currently, I am getting error I am passing designation address in array. But If i will as object then it will work fine. But I need to pass more than one address in single transaction.
Can you please give solution ASAP about it?