Last active
August 11, 2023 23:18
-
-
Save WietseWind/557a5c11fa0d474468e8c9c54e3e5b93 to your computer and use it in GitHub Desktop.
XRPL Accountlib & XRPL Client together
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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