Created
June 19, 2023 18:30
-
-
Save WietseWind/9650f3c258ce4fc0574cd5f7ef0effba to your computer and use it in GitHub Desktop.
Custom Definitions with XRPL Accountlib
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
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