Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bitcoinjs/bip21
A BIP21 compatible URL encoding utility library
https://github.com/bitcoinjs/bip21
bip21 bitcoin javascript
Last synced: about 1 month ago
JSON representation
A BIP21 compatible URL encoding utility library
- Host: GitHub
- URL: https://github.com/bitcoinjs/bip21
- Owner: bitcoinjs
- License: mit
- Created: 2014-10-29T14:52:25.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-07-20T04:18:04.000Z (5 months ago)
- Last Synced: 2024-10-29T20:47:44.134Z (about 1 month ago)
- Topics: bip21, bitcoin, javascript
- Language: JavaScript
- Size: 155 KB
- Stars: 55
- Watchers: 12
- Forks: 44
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-wallet - BIP21
- awesome-cryptocoinjs - bitcoin
README
# bip21
[![build status](https://secure.travis-ci.org/bitcoinjs/bip21.png)](http://travis-ci.org/bitcoinjs/bip21)
[![Version](http://img.shields.io/npm/v/bip21.svg)](https://www.npmjs.org/package/bip21)A [BIP21](https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki) compatible URL encoding library.
## Example
``` javascript
var bip21 = require('bip21')var decoded = bip21.decode('bitcoin:1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH?amount=20.3&label=Foobar')
console.log(decoded)
// { address: '1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH',
// options: {
// amount: 20.3,
// label: 'Foobar' }
// }
//
// WARNING: Remember to error check the `.address`!console.log(bip21.encode('1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH'))
// => bitcoin:1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMHconsole.log(bip21.encode('1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH', {
amount: 20.3,
label: 'Foobar'
}))
// => bitcoin:1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH?amount=20.3&label=Foobar
```## License [MIT](LICENSE)