Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
A lightweight JavaScript sdk to connect to the Blocknative backend Ethereum node infrastructure via a websocket connection for realtime transaction updates.
npm install bnc-sdk
import WebSocket from 'ws'
import BlocknativeSdk from 'bnc-sdk'
import Web3 from 'web3'
const web3 = new Web3('<ws://some.local-or-remote.node:8546>')
// create options object
const options = {
dappId: '<YOUR_API_KEY>',
networkId: 4,
ws: WebSocket
// un-comment if you would like to log all transaction events
// transactionHandlers: [event => console.log(event.transaction)]
}
// initialize and connect to the api
const blocknative = new BlocknativeSdk(options)
const txOptions = {
to: '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D',
value: 1000000000000000
}
// initiate a transaction via web3.js
web3.eth.sendTransaction(txOptions).on('transactionHash', hash => {
// call with the transaction hash of the transaction that you would like to receive status updates for
const { emitter } = blocknative.transaction(hash)
// listen to some events
emitter.on('txPool', transaction => {
console.log(`Sending ${transaction.value} wei to ${transaction.to}`)
})
emitter.on('txConfirmed', transaction => {
console.log('Transaction is confirmed!')
})
// catch every other event that occurs and log it
emitter.on('all', transaction => {
console.log(`Transaction event: ${transaction.eventCode}`)
})
})
import WebSocket from 'ws'
import BlocknativeSdk from 'bnc-sdk'
import Web3 from 'web3'
const web3 = new Web3('<ws://some.local-or-remote.node:8546>')
// create options object
const options = {
dappId: '<YOUR_API_KEY>',
networkId: 4,
ws: WebSocket
// un-comment if you would like to log all transaction events
// transactionHandlers: [event => console.log(event.transaction)]
}
// initialize and connect to the api
const blocknative = new BlocknativeSdk(options)
const address = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'
const { emitter, details } = blocknative.account(address)
emitter.on('all', transaction => {
console.log(transaction)
})
import BlocknativeSdk from 'bnc-sdk'
import Web3 from 'web3'
const web3 = new Web3(window.ethereum)
// create options object
const options = {
dappId: '<YOUR_API_KEY>',
networkId: 4
// un-comment if you would like to log all transaction events
// transactionHandlers: [event => console.log(event.transaction)]
}
// initialize and connect to the api
const blocknative = new BlocknativeSdk(options)
const txOptions = {
to: '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D',
value: 1000000000000000
}
// initiate a transaction via web3.js
web3.eth.sendTransaction(txOptions).on('transactionHash', hash => {
// call with the transaction hash of the transaction that you would like to receive status updates for
const { emitter } = blocknative.transaction(hash)
// listen to some events
emitter.on('txPool', transaction => {
console.log(`Sending ${transaction.value} wei to ${transaction.to}`)
})
emitter.on('txConfirmed', transaction => {
console.log('Transaction is confirmed!')
})
// catch every other event that occurs and log it
emitter.on('all', transaction => {
console.log(`Transaction event: ${transaction.eventCode}`)
})
})
#### Address Listener
```javascript
import BlocknativeSdk from 'bnc-sdk'
import Web3 from 'web3'
const web3 = new Web3(window.ethereum)
// create options object
const options = {
dappId: '<YOUR_API_KEY>',
networkId: 4
// un-comment if you would like to log all transaction events
// transactionHandlers: [event => console.log(event.transaction)]
}
// initialize and connect to the api
const blocknative = new BlocknativeSdk(options)
const address = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'
const { emitter, details } = blocknative.account(address)
emitter.on('all', transaction => {
console.log(transaction)
})
For detailed documentation head to docs.blocknative.com
FAQs
SDK to connect to the blocknative backend via a websocket connection
The npm package bnc-sdk receives a total of 7,130 weekly downloads. As such, bnc-sdk popularity was classified as popular.
We found that bnc-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.