Skip to content

Instantly share code, notes, and snippets.

@WietseWind
Created May 29, 2024 22:00
Show Gist options
  • Save WietseWind/5daca6762472467895738fe4e9ca4be3 to your computer and use it in GitHub Desktop.
Save WietseWind/5daca6762472467895738fe4e9ca4be3 to your computer and use it in GitHub Desktop.
Sign & Submit transactions on XRPL and Xahau (testnet, mainnet, multiple nodes)
import { derive, utils, prefilledSignAndSubmit, XrplClient } from "xrpl-accountlib"
const sample = 'xahauTestnet'
const sampleValues = {
xahauTestnet: {
account: derive.familySeed('sstWn1vCjnf6vFT87QHoYJpzYrdu9'),
nodes: [
new XrplClient('wss://xahau-test.net'),
new XrplClient('wss://hooks-testnet-v3.xrpl-labs.com'),
]
},
xrplTestnet: {
account: derive.familySeed('sEdSouZhfBKCvhXfFMBGR7TLDM9mNRn'),
nodes: [
new XrplClient('wss://testnet.xrpl-labs.com'),
new XrplClient('wss://s.altnet.rippletest.net:51233/'),
]
},
xahauMainnet: {
account: {}, // derive.familySeed...
nodes: [
new XrplClient('wss://xahau.network'),
new XrplClient('wss://xahau.org/explorers/c14'),
]
},
xrplMainnet: {
account: {}, // derive.familySeed...
nodes: [
new XrplClient('wss://xrplcluster.com'),
new XrplClient('wss://s2.ripple.com'),
]
},
}
const tx = {
TransactionType: 'Payment',
Destination: 'rwietsevLFg8XSmG3bEZzFein1g8RBqWDZ',
Amount: String(10 * 1_000_000), // Drops, one millionth XRP/XAH, so this is 10 XRP/XAH, as string
};
const submitted = await Promise.all(sampleValues[sample].nodes.map(node => prefilledSignAndSubmit(tx, node, sampleValues[sample].account)))
console.log(submitted)
const allConnections = Object.keys(sampleValues).map(sample => sampleValues[sample].nodes).flat()
allConnections.forEach(conn => conn.close())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment