Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blocknative/notify
https://github.com/blocknative/notify
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/blocknative/notify
- Owner: blocknative
- License: mit
- Created: 2019-06-25T22:17:21.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-27T04:46:03.000Z (almost 2 years ago)
- Last Synced: 2024-10-27T22:27:27.372Z (about 2 months ago)
- Language: TypeScript
- Size: 1.88 MB
- Stars: 48
- Watchers: 16
- Forks: 9
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-web3 - notify - JavaScript library for real time notifications for Ethereum transaction state changes. (Software Development / JavaScript)
README
# Notify
A JavaScript library for real time notifications for Ethereum transaction state changes.
## Install
`npm install bnc-notify`
## Quick Start
```javascript
import Notify from 'bnc-notify'
import Web3 from 'web3'const web3 = new Web3(window.ethereum)
const options = {
dappId: 'Your dappId here',
networkId: 1
}// initialize notify
const notify = Notify(options)// get users' account address
const accounts = await window.ethereum.enable()// send a transaction
web3.eth
.sendTransaction({
from: accounts[0],
to: '0x792ec62e6840bFcCEa00c669521F678CE1236705',
value: '100000'
})
// listen for transaction hash
.on('transactionHash', hash => {
// pass the hash to notify.hash function for transaction updates and notifications
const { emitter } = notify.hash(hash)// use emitter to listen to transaction events
emitter.on('txSent', console.log)
emitter.on('txPool', console.log)
emitter.on('txConfirmed', console.log)
emitter.on('txSpeedUp', console.log)
emitter.on('txCancel', console.log)
emitter.on('txFailed', console.log)
emitter.on('txStuck', console.log)
emitter.on('all', console.log)
})
```## Documentation
For detailed documentation head to [docs.blocknative.com](https://docs.blocknative.com/notify)