Files
xrpl-dev-portal/content/_code-samples/secure-signing/js/signPayment.js
mDuo13 984533a702 Set Up Secure Signing: edits per reviews
- Moved the LAN config tutorial to its own (draft) file to be finished later
- Mentioned dedicated signing devices such as the Ledger Nano S
- Improved the JS example's handling of secrets
2019-02-27 15:11:41 -08:00

26 lines
678 B
JavaScript

'use strict'
const RippleAPI = require('ripple-lib').RippleAPI
// Load address & secret from environment variables:
const from_address = process.env['MY_ADDRESS']
const secret = process.env['MY_SECRET']
// Can sign offline if the txJSON has all required fields
const api = new RippleAPI()
const txJSON = JSON.stringify({
"Account": from_address,
"TransactionType":"Payment",
"Destination":"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
"Amount":"13000000",
"Flags":2147483648,
"LastLedgerSequence":7835923,
"Fee":"13",
"Sequence":2
})
const signed = api.sign(txJSON, secret)
console.log("tx_blob is:", signed.signedTransaction)
console.log("tx hash is:", signed.id)