api.connect().then(() => {
const preparedTx = await api.prepareTransaction({
"TransactionType": "Payment",
"Account": sender,
"Amount": api.xrpToDrops(amount),
"Destination": destination,
}, {
// Expire this transaction if it doesn't execute within ~5 minutes:
"maxLedgerVersionOffset": 75
})
const maxLedgerVersion = preparedTx.instructions.maxLedgerVersion
return preparedTx.txJSON
}).then(txJSON => {
const response = api.sign(txJSON, secret)
const txID = response.id
const txBlob = response.signedTransaction
return txBlob;
}).then(txBlob => {
const latestLedgerVersion = await api.getLedgerVersion()
const result = await api.submit(txBlob)
return latestLedgerVersion + 1
}).then((earliestLedgerVersion) => {
return api.disconnect();
}).then(() => {
process.exit();
}).catch(console.error);