mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-26 06:35:51 +00:00
Checks tutorial: separate signing for CheckCreate
This commit is contained in:
33
content/code_samples/checks/js/prepareCreate.js
Normal file
33
content/code_samples/checks/js/prepareCreate.js
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict'
|
||||
const RippleAPI = require('ripple-lib').RippleAPI
|
||||
|
||||
// This example connects to a public Test Net server
|
||||
const api = new RippleAPI({server: 'wss://s.altnet.rippletest.net:51233'})
|
||||
api.connect().then(() => {
|
||||
console.log('Connected')
|
||||
|
||||
const sender = 'rBXsgNkPcDN2runsvWmwxk3Lh97zdgo9za'
|
||||
const receiver = 'rGPnRH1EBpHeTF2QG8DCAgM7z5pb75LAis'
|
||||
const options = {
|
||||
// Allow up to 60 ledger versions (~5 min) instead of the default 3 versions
|
||||
// before this transaction fails permanently.
|
||||
"maxLedgerVersionOffset": 60
|
||||
}
|
||||
return api.prepareCheckCreate(sender, {
|
||||
"destination": receiver,
|
||||
"sendMax": {
|
||||
"currency": "XRP",
|
||||
"value": "100" // RippleAPI uses decimal XRP, not integer drops
|
||||
}
|
||||
}, options)
|
||||
|
||||
}).then(prepared => {
|
||||
console.log("txJSON:", prepared.txJSON);
|
||||
|
||||
// Disconnect and return
|
||||
}).then(() => {
|
||||
api.disconnect().then(() => {
|
||||
console.log('Disconnected')
|
||||
process.exit()
|
||||
})
|
||||
}).catch(console.error)
|
||||
Reference in New Issue
Block a user