Skip to content

Instantly share code, notes, and snippets.

@WietseWind
Created June 19, 2023 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WietseWind/9650f3c258ce4fc0574cd5f7ef0effba to your computer and use it in GitHub Desktop.
Save WietseWind/9650f3c258ce4fc0574cd5f7ef0effba to your computer and use it in GitHub Desktop.
Custom Definitions with XRPL Accountlib
const { XrplClient } = require('xrpl-client')
const { sign, derive, XrplDefinitions } = require('xrpl-accountlib')
const client = new XrplClient('wss://hooks-testnet-v3.xrpl-labs.com')
const account = derive.familySeed("s....")
const liveDefinitions = await client.send({ command: 'server_definitions' })
const definitions = new XrplDefinitions(liveDefinitions)
const ledgerInfo = await client.send({
command: 'ledger'
})
// console.log(ledgerInfo)
const accountInfo = await client.send({
command: 'account_info',
account: account.address,
})
// console.log(accountInfo)
const txJsonPreSigning = {
TransactionType: 'Payment',
Account: account.address,
Destination: 'r...',
Fee: '2000',
Amount: '10000',
LastLedgerSequence: Number(ledgerInfo.closed.ledger.seqNum) + 20,
Sequence: accountInfo.account_data.Sequence,
NetworkID: 21338,
}
const signed = sign(txJsonPreSigning, account, definitions)
console.log('Tx', signed.id)
console.log(signed.signedTransaction)
const submit = await client.send({
command: 'submit',
tx_blob: signed.signedTransaction
})
console.log(submit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment