# eth-url-parser

> Ethereum url parsing library

Latest version **1.0.4** (published 2021-08-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install eth-url-parser
pnpm add eth-url-parser
yarn add eth-url-parser
bun add eth-url-parser
```

## Health

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

Positive: has types package; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2021-08-20 |
| First published | 2018-09-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/eth-url-parser) |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 292.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 31 |
| Author | Bruno Barbieri |
| Maintainers | brunobar79 |
| Keywords | ethereum, url, parser, eip681, erc681, web3 |

## Links

- npm: https://www.npmjs.com/package/eth-url-parser
- Repository: git@github.com:brunobar79/eth-url-parser
- npm.io page: https://npm.io/package/eth-url-parser

## Dependencies (2)

- [qs](https://npm.io/package/qs.md) ^6.5.2
- [bignumber.js](https://npm.io/package/bignumber.js.md) ^7.2.1

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2021-08-20
- 1.0.3 — 2019-06-07
- 1.0.2 — 2018-09-11
- 1.0.1 — 2018-09-11
- 1.0.0 — 2018-09-11

## README

# eth-url-parser

[![npm](https://img.shields.io/npm/v/eth-url-parser.svg)](https://npmjs.com/package/eth-url-parser) [![npm](https://img.shields.io/npm/dm/eth-url-parser.svg)](https://npmjs.com/package/eth-url-parser) 
![CircleCI branch](https://img.shields.io/circleci/project/github/brunobar79/eth-url-parser/master.svg)


Module that supports parsing / parsing of all the different ethereum standard urls: [ERC-681](https://eips.ethereum.org/EIPS/eip-681) and [ERC-831](https://eips.ethereum.org/EIPS/eip-831)

This module contains two functions:

## `parse(string)`

Takes in a string of an Ethereum URL and returns an object matching that URL according to the previously mentioned standards
The returned object looks like this:

```javascript
{
    scheme: 'ethereum',
    target_address: '0x1234DEADBEEF5678ABCD1234DEADBEEF5678ABCD', // ENS names are also supported!
    chain_id: '1',
    parameters: {
        'value': '2014000000000000000', // (in WEI)
        'gas': '45000', // can be also gasLimit
        'gasPrice': '50',
    }
}
```

## `build(object)`

Takes in an object representing the different parts of the ethereum url and returns a string representing a valid ethereum url

## Getting started

`$ npm install eth-url-parser --save`

## Usage

```javascript
import { parse, build } from 'eth-url-parser';

const parsedUrl = parse('ethereum:0x1234DEADBEEF5678ABCD1234DEADBEEF5678ABCD')
console.log(parseUrl.target_address)
// '0x1234DEADBEEF5678ABCD1234DEADBEEF5678ABCD'

const url =  build({
        scheme: 'ethereum',
        prefix: 'pay',
        target_address: '0x1234DEADBEEF5678ABCD1234DEADBEEF5678ABCD'
    });
console.log(url);
// 'ethereum:pay-0x1234DEADBEEF5678ABCD1234DEADBEEF5678ABCD'

```

## License

MIT

## Credits

This repo is a combination of [erc681](https://github.com/parity-js/erc681) (by [@parity-js](https://github.com/parity-js)) and [eip681](https://github.com/tokenkit/eip681/) (by [tokenkit](https://github.com/tokenkit))

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