# xpop

> Generate xPOP based on source data (ledger, tx, validations)

Latest version **1.1.2** (published 2023-11-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install xpop
pnpm add xpop
yarn add xpop
bun add xpop
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2023-11-20 |
| First published | 2023-10-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 1.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Wietse Wind |
| Maintainers | wietsewind |

## Links

- npm: https://www.npmjs.com/package/xpop
- Repository: https://github.com/Xahau/JS-xPOP-Retrieve-Generate
- Homepage: https://github.com/Xahau/JS-xPOP-Retrieve-Generate/#readme
- Issues: https://github.com/Xahau/JS-xPOP-Retrieve-Generate/issues
- npm.io page: https://npm.io/package/xpop

## Dependencies (2)

- [xpopgen](https://npm.io/package/xpopgen.md) ^1.0.0
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.7.0

## Recent versions

- 1.1.2 (latest) — 2023-11-20
- 1.1.1 — 2023-11-20
- 1.1.0 — 2023-11-20
- 1.0.5 — 2023-10-08
- 1.0.4 — 2023-10-08
- 1.0.3 — 2023-10-08
- 1.0.2 — 2023-10-06
- 1.0.0 — 2023-10-06

## README

# XPOP Fetching / Generation [![npm version](https://badge.fury.io/js/xpop.svg)](https://badge.fury.io/js/xpop)

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"](https://github.com/Xahau/Validation-Ledger-Tx-Store-to-xPOP)

Methods to retrieve/generate, in order (unless params provided, see below):

1. Fetch ready to use HEX XPOP
2. Fetch JSON XPOP and encode to HEX
3. Fetch source files & compile XPOP & encode to HEX

## Samples

Sample to generate & submit a B2M transaction on Testnet, resulting in an xPOP:
- https://gist.github.com/WietseWind/cd8a7a8c88f218fe7b768f59a665685d

Sample to use this script in the browser:
- https://jsfiddle.net/WietseWind/42kpm0hr/

## 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:
- https://jsfiddle.net/WietseWind/42kpm0hr/

## Methods

- `setVerbose(bool)` » `console.log` verbose info if true
- `setEndpoints(string[])` » [ Mandatory ] - the URLs where [the collector is running](https://github.com/Xahau/Validation-Ledger-Tx-Store-to-xPOP)
- `xpop(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)

```javascript
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:

```javascript
// tx hash
xpop('20D193C6E615D86BCC13A5DAB781852A6672F3E627D33FBAE62053F1178740BB')
```

## Pre-generated XPOP with fallback to pre-generated JSON

```javascript
// tx hash, ledger index, network id
xpop('20D193C6E615D86BCC13A5DAB781852A6672F3E627D33FBAE62053F1178740BB', 41815218, 1)
```

## Forced pre-generated / client side generated (fallback) JSON

```javascript
// tx hash, ledger index, network id, true (force)
xpop('20D193C6E615D86BCC13A5DAB781852A6672F3E627D33FBAE62053F1178740BB', 41815218, 1, true)
```

---
_Source: https://npm.io/package/xpop · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
