Skip to content

Instantly share code, notes, and snippets.

@WietseWind
Last active August 11, 2023 23:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WietseWind/557a5c11fa0d474468e8c9c54e3e5b93 to your computer and use it in GitHub Desktop.
Save WietseWind/557a5c11fa0d474468e8c9c54e3e5b93 to your computer and use it in GitHub Desktop.
XRPL Accountlib & XRPL Client together
//
// NOTE! THERE'S A BETTER METHOD NOW:
// https://github.com/WietseWind/xrpl-accountlib#-however-since-version-210-this-lib-bundles-xrpl-client-as-well-and-comes-with-helpers-to-prepare-transactions--submit-transactions-
//
const lib = require('xrpl-accountlib')
const { XrplClient } = require('xrpl-client')
const secret = 's...'
const account = 'r...' // Can be derived
const client = new XrplClient('wss://hooks-testnet.xrpl-labs.com')
const keypair = lib.derive.familySeed(secret)
const main = async () => {
console.log('Getting ready...')
const { account_data } = await client.send({ command: 'account_info', account })
const tx = {
TransactionType: 'Payment',
Account: account,
Amount: '1',
Destination: 'rwietsevLFg8XSmG3bEZzFein1g8RBqWDZ',
Fee: '12',
Sequence: account_data.Sequence
}
const {signedTransaction} = lib.sign(tx, keypair)
const submit = await client.send({ command: 'submit', 'tx_blob': signedTransaction })
console.log(submit.engine_result, submit.engine_result_message, submit.tx_json.hash)
console.log('Shutting down...')
client.close()
}
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment