Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bnc-sdk

Package Overview
Dependencies
Maintainers
3
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bnc-sdk - npm Package Compare versions

Comparing version 3.7.0 to 3.7.1

2

package.json
{
"name": "bnc-sdk",
"version": "3.7.0",
"version": "3.7.1",
"description": "SDK to connect to the blocknative backend via a websocket connection",

@@ -5,0 +5,0 @@ "keywords": [

@@ -11,8 +11,89 @@ # Blocknative sdk

### Quick Start (client)
### Quick Start (Node.js)
#### Transaction Monitor
```javascript
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}`)
})
})
```
#### Address Listener
```javascript
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)
})
```
### Quick Start (Browser)
#### Transaction Monitor
```javascript
import BlocknativeSdk from 'bnc-sdk'
import Web3 from 'web3'
const web3 = new Web3(window.ethereum)

@@ -22,5 +103,6 @@

const options = {
dappId: 'Your dappId here',
networkId: 1,
transactionHandlers: [event => console.log(event.transaction)]
dappId: '<YOUR_API_KEY>',
networkId: 4
// un-comment if you would like to log all transaction events
// transactionHandlers: [event => console.log(event.transaction)]
}

@@ -31,2 +113,7 @@

const txOptions = {
to: '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D',
value: 1000000000000000
}
// initiate a transaction via web3.js

@@ -50,2 +137,30 @@ web3.eth.sendTransaction(txOptions).on('transactionHash', hash => {

})
})
#### 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)
})
```

@@ -52,0 +167,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc