Blocknative sdk
A lightweight JavaScript sdk to connect to the Blocknative backend Ethereum node infrastructure via a websocket connection for realtime transaction updates.
Usage
Installation
npm install bnc-sdk
Quick Start (client)
import blocknativeSdk from 'bnc-sdk'
import Web3 from 'web3'
const web3 = new Web3(window.ethereum)
const options = {
dappId: 'Your dappId here',
networkId: 1,
transactionHandlers: [event => console.log(event.transaction)]
}
const blocknative = new BlocknativeSdk(options)
web3.eth.sendTransaction(txOptions).on('transactionHash', hash => {
const { emitter } = blocknative.transaction(hash)
emitter.on('txPool', transaction => {
console.log(`Sending ${transaction.value} wei to ${transaction.to}`)
})
emitter.on('txConfirmed', transaction => {
console.log('Transaction is confirmed!')
})
emitter.on('all', transaction => {
console.log(`Transaction event: ${transaction.eventCode}`)
})
Documentation
For detailed documentation head to docs.blocknative.com