Skip to content

Instantly share code, notes, and snippets.

@WietseWind
Last active December 12, 2018 18:33
Show Gist options
  • Save WietseWind/e5310ca295a18aedad0617a586657cb7 to your computer and use it in GitHub Desktop.
Save WietseWind/e5310ca295a18aedad0617a586657cb7 to your computer and use it in GitHub Desktop.
XRP (XRPL) EscrowCreate using NodeJS (featuring Memos) - Used for: https://twitter.com/WietseWind/status/998968185532579840
const RippledWsClient = require('rippled-ws-client')
const RippledWsClientSign = require('rippled-ws-client-sign')
const SeedOrKeypair = 'sXXXXXXXXXXXXXXXXXXXX' // The secret of the sending wallet
// const FinishAfter = Math.floor(new Date('2031-12-01T12:00:00Z') / 1000) - 946684800 /* XRPL Timestamp offset */
const FinishAfter = Math.floor(Date.parse('2018-10-10 12:00:00 GMT+1') / 1000) - 946684800 /* XRPL Timestamp offset */
const Transaction = {
TransactionType: 'EscrowCreate',
Account: 'rSENDINGWALLET',
Destination: 'rRECEIVINGWALLET',
FinishAfter: FinishAfter,
Amount: 1 * 1000000, // Amount in drops, so multiply (6 decimal positions), this is 1 XRP
LastLedgerSequence: null,
Fee: 12,
Memos: [
{
Memo: {
MemoType: Buffer.from('Sometext over here', 'utf8').toString('hex').toUpperCase(),
MemoData: Buffer.from('Some more text over here', 'utf8').toString('hex').toUpperCase()
}
},
{
Memo: {
MemoData: Buffer.from('And more text', 'utf8').toString('hex').toUpperCase()
}
}
]
}
new RippledWsClient('wss://s1.ripple.com').then((Connection) => {
new RippledWsClientSign(Transaction, SeedOrKeypair, Connection).then((TransactionSuccess) => {
console.log('TransactionSuccess', TransactionSuccess)
Connection.close()
}).catch((SignError) => {
console.log('SignError', SignError.details)
Connection.close()
})
}).catch((ConnectionError) => {
console.log('ConnectionError', ConnectionError)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment