Skip to content

Instantly share code, notes, and snippets.

@WietseWind
Last active October 31, 2023 14:06
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/8255ad8d31506b9567639fe16cbdc7ff to your computer and use it in GitHub Desktop.
Save WietseWind/8255ad8d31506b9567639fe16cbdc7ff to your computer and use it in GitHub Desktop.
Send TX on Xahau mainnet
import { generate, utils, signAndSubmit } from 'xrpl-accountlib'
for (let i = 0; i < 20; i++) {
const account = generate.familySeed({ algorithm: 'ed25519' })
console.log(`${account.address}\t${account.secret.familySeed}\t${account.keypair.privateKey}`)
}
import { derive, utils, signAndSubmit } from 'xrpl-accountlib'
import { XrplClient } from 'xrpl-client'
// RUN:
// node send.mjs originRaddress regularKeySecret destinationRaddress
const account = derive.familySeed(process.argv[3])
Object.assign(account, { address: process.argv[2], })
const nodes = {
xahau: [
new XrplClient('wss://xahau.network'),
]
}
console.log('Waiting for network connections to be ready')
await Promise.all(Object.keys(nodes).map(k => Promise.race(nodes[k].map(n => n.ready()))))
const [
xahauParams,
] = await Promise.all([
Promise.race(nodes.xahau.map(n => utils.accountAndLedgerSequence(n, account))),
])
const tx = {
...xahauParams.txValues,
TransactionType: 'Payment',
Fee: '10',
Destination: process.argv[4],
Amount: String(Number(process.argv[5]) * 1_000_000),
}
console.log('Submitting TX')
const txsubm = await Promise.race(nodes.xahau.map(n => signAndSubmit(tx, n, account)))
console.log(' -->', 'Submitted! TX on Xahau mainnet:')
console.log(' -->', 'https://xahauexplorer.com/explorer/' + txsubm?.tx_id)
console.log(' -->', txsubm.response.engine_result, txsubm.response.engine_result_message)
// Closing connections
Object.keys(nodes).map(k => nodes[k].map(n => n.close()))
import { derive, utils, signAndSubmit } from 'xrpl-accountlib'
import { XrplClient } from 'xrpl-client'
const account = derive.familySeed('s.... secret')
const Destination = 'r...'
const xrpToSend = 20
const nodes = { xahau: [ new XrplClient('wss://xahau.network'), ] }
console.log('Waiting for network connections to be ready')
await Promise.all(Object.keys(nodes).map(k => Promise.race(nodes[k].map(n => n.ready()))))
const [ xahauParams, ] = await Promise.all([ Promise.race(nodes.xahau.map(n => utils.accountAndLedgerSequence(n, account))), ])
const tx = {
...xahauParams.txValues,
TransactionType: 'Payment',
Destination,
Amount: String(Number(xrpToSend) * 1_000_000),
}
console.log('Submitting TX')
const txsubm = await Promise.race(nodes.xahau.map(n => signAndSubmit(tx, n, account)))
console.log(' -->', 'Submitted! TX on Xahau mainnet:')
console.log(' -->', 'https://xahauexplorer.com/explorer/' + txsubm?.tx_id)
console.log(' -->', txsubm.response.engine_result, txsubm.response.engine_result_message)
// Closing connections
Object.keys(nodes).map(k => nodes[k].map(n => n.close()))
import { derive, utils, signAndSubmit } from 'xrpl-accountlib'
import { XrplClient } from 'xrpl-client'
// Use:
// node setregularkey.mjs originAccountSecret rekeyToRaddress
const account = derive.familySeed(process.argv[2])
const nodes = {
xahau: [
new XrplClient('wss://xahau.network'),
]
}
console.log('Waiting for network connections to be ready')
await Promise.all(Object.keys(nodes).map(k => Promise.race(nodes[k].map(n => n.ready()))))
const [
xahauParams,
] = await Promise.all([
Promise.race(nodes.xahau.map(n => utils.accountAndLedgerSequence(n, account))),
])
const tx = {
...xahauParams.txValues,
TransactionType: 'SetRegularKey',
Fee: '10',
RegularKey: process.argv[3],
}
console.log('Submitting TX')
const txsubm = await Promise.race(nodes.xahau.map(n => signAndSubmit(tx, n, account)))
console.log(' -->', 'Submitted! TX on Xahau mainnet:')
console.log(' -->', 'https://xahauexplorer.com/explorer/' + txsubm?.tx_id)
console.log(' -->', txsubm.response.engine_result, txsubm.response.engine_result_message)
// Closing connections
Object.keys(nodes).map(k => nodes[k].map(n => n.close()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment