mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-27 23:25:51 +00:00
Re-level non-docs content to top of repo and rename content→docs
This commit is contained in:
28
_code-samples/secure-signing/js/signPayment.js
Normal file
28
_code-samples/secure-signing/js/signPayment.js
Normal file
@@ -0,0 +1,28 @@
|
||||
// Sample code demonstrating secure offline signing using xrpl.js library.
|
||||
const xrpl = require('xrpl')
|
||||
|
||||
// Load seed value from an environment variable:
|
||||
const my_wallet = xrpl.Wallet.fromSeed(process.env['MY_SEED'])
|
||||
|
||||
// For offline signing, you need to know your address's next Sequence number.
|
||||
// Alternatively, you could use a Ticket in place of the Sequence number.
|
||||
// This is useful when you need multiple signatures and may want to process transactions out-of-order.
|
||||
// For details, see: https://xrpl.org/tickets.html
|
||||
let my_seq = 21404872
|
||||
|
||||
// Provide *all* required fields before signing a transaction
|
||||
const txJSON = {
|
||||
"Account": my_wallet.address,
|
||||
"TransactionType":"Payment",
|
||||
"Destination":"rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn",
|
||||
"Amount":"13000000",
|
||||
"Flags":2147483648,
|
||||
"LastLedgerSequence":7835923, // Optional, but recommended.
|
||||
"Fee":"13",
|
||||
"Sequence": my_seq
|
||||
}
|
||||
|
||||
const signed = my_wallet.sign(txJSON)
|
||||
|
||||
console.log("tx_blob is:", signed.tx_blob)
|
||||
console.log("tx hash is:", signed.hash)
|
||||
Reference in New Issue
Block a user