1.1.2 • Published 1 year ago
xpop v1.1.2
XPOP Fetching / Generation
This lib. fetches a ready to use xPOP, fetches and encodes a JSON xPOP or even generates the entire xPOP based on sources running the xPOP source data service: "Validation Ledger & Transaction Store"
Methods to retrieve/generate, in order (unless params provided, see below):
- Fetch ready to use HEX XPOP
- Fetch JSON XPOP and encode to HEX
- Fetch source files & compile XPOP & encode to HEX
Samples
Sample to generate & submit a B2M transaction on Testnet, resulting in an xPOP:
Sample to use this script in the browser:
Output
null
(failed) or HEX encoded XPOP ready to use for import in the Blob
field.
NPM, CDN
- NPM (backend): https://www.npmjs.com/package/xpop
- CDN (browser): https://cdn.jsdelivr.net/npm/xpop/browser.min.js
Example browser implementation:
Methods
setVerbose(bool)
»console.log
verbose info if truesetEndpoints(string[])
» Mandatory - the URLs where the collector is runningxpop(tx hash [, ledger index, network id, force ])
JS/Browser
Note: a list of recent endpoints can be found here:
- https://xrpl.ws-stats.com/xpop/list
- https://xrpl.ws-stats.com/xpop/list?json=true (see auto-fill example below)
const {setVerbose, setEndpoints, xpop} = require('xpop')
// setVerbose(true)
// setEndpoints((await (await fetch('https://xrpl.ws-stats.com/xpop/list?json=true')).json()).bestguess)
setEndpoints([
'https://xpop.xrplwin.com/', // Twitter: @XRPLWin
'http://xpop.katczynski.org', // Twitter: @realkatczynski
'https://xpop.xrpl-labs.com', // Twitter: @XRPLLabs
])
xpop('20D193C6E615D86BCC13A5DAB781852A6672F3E627D33FBAE62053F1178740BB', 41815218, 1, true)
.then(console.log)
Pre-generated XPOP only:
// tx hash
xpop('20D193C6E615D86BCC13A5DAB781852A6672F3E627D33FBAE62053F1178740BB')
Pre-generated XPOP with fallback to pre-generated JSON
// tx hash, ledger index, network id
xpop('20D193C6E615D86BCC13A5DAB781852A6672F3E627D33FBAE62053F1178740BB', 41815218, 1)
Forced pre-generated / client side generated (fallback) JSON
// tx hash, ledger index, network id, true (force)
xpop('20D193C6E615D86BCC13A5DAB781852A6672F3E627D33FBAE62053F1178740BB', 41815218, 1, true)