const read = require('read').read;
const send = require('./send');
async function asyncMain()
{
const amount = await read({
prompt: "Amount: "
});
const password = await read({
prompt: "Password: ",
silent: true,
replace: "*" //optional, will print out an asterisk for every typed character
});
// console.log("Amount: " + amount);
// console.log("Your password: " + password);
await send(
{
server: 'wss://s1.ripple.com',
fromAddress: "*****************************",
toAddress: "*****************************",
tag : 1111111111,
amount : amount,
secret : password
}
);
console.log("Done!");
}
asyncMain();
send.js
:
const RippleAPI = require('ripple-lib').RippleAPI;
module.exports = function send({server, fromAddress, toAddress, tag, amount, secret})
{
const instructions = {maxLedgerVersionOffset: 5};
const currency = 'XRP';
const payment = {
source: {
address: fromAddress,
maxAmount: {
value: amount,
currency: currency
}
},
destination: {
address: toAddress,
amount: {
value: amount,
currency: currency
},
tag: tag
}
};
const api = new RippleAPI({
server: server
});
return api.connect().then(() => {
console.log('Connected...')
api.preparePayment(fromAddress, payment, instructions).then(prepared => {
const {signedTransaction, id} = api.sign(prepared.txJSON, secret)
console.log(id)
api.submit(signedTransaction).then(result => {
console.log(JSON.stringify(result, null, 2))
api.disconnect()
})
})
}).catch(console.error);
}
Create Accounts and Send XRP Using Python:
https://xrpl.org/docs/tutorials/python/send-payments/create-accounts-send-xrp
XRPLF/xrpl-dev-portal:
https://github.com/XRPLF/xrpl-dev-portal/tree/master/_code-samples/quickstart/py/