{"id":18738057,"url":"https://github.com/blocknative/sdk","last_synced_at":"2025-09-10T00:39:49.144Z","repository":{"id":37617244,"uuid":"201181147","full_name":"blocknative/sdk","owner":"blocknative","description":"Library to connect to the Blocknative backend via a websocket connection","archived":false,"fork":false,"pushed_at":"2024-05-03T17:03:56.000Z","size":694,"stargazers_count":105,"open_issues_count":9,"forks_count":26,"subscribers_count":16,"default_branch":"develop","last_synced_at":"2025-09-07T00:59:46.949Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://blocknative.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blocknative.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-08T04:57:50.000Z","updated_at":"2025-08-07T03:01:47.000Z","dependencies_parsed_at":"2024-06-18T13:46:08.914Z","dependency_job_id":"6c9c0cc3-a51a-4bc2-822d-1b918d7f8a67","html_url":"https://github.com/blocknative/sdk","commit_stats":{"total_commits":259,"total_committers":12,"mean_commits":"21.583333333333332","dds":"0.27413127413127414","last_synced_commit":"9868e019a2b0f038d458c193e42c8c25d465e955"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"purl":"pkg:github/blocknative/sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blocknative%2Fsdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blocknative%2Fsdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blocknative%2Fsdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blocknative%2Fsdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blocknative","download_url":"https://codeload.github.com/blocknative/sdk/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blocknative%2Fsdk/sbom","scorecard":{"id":243781,"data":{"date":"2025-08-11","repo":{"name":"github.com/blocknative/sdk","commit":"b75a27073919e0fc126435382e0ab93dab3508f0"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.8,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":10,"reason":"all changesets reviewed","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/issue-to-notion.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/blocknative/sdk/issue-to-notion.yml/develop?enable=pin","Info:   0 out of   1 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/issue-to-notion.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"12 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-mpj8-q39x-wq5h","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T07:08:19.344Z","repository_id":37617244,"created_at":"2025-08-17T07:08:19.345Z","updated_at":"2025-08-17T07:08:19.345Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274051961,"owners_count":25214030,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T15:28:01.252Z","updated_at":"2025-09-10T00:39:49.095Z","avatar_url":"https://github.com/blocknative.png","language":"TypeScript","readme":"# Blocknative sdk\n\nA lightweight JavaScript sdk to connect to the Blocknative backend Ethereum node infrastructure via a websocket connection for realtime transaction updates.\n\n## Usage\n\n### Installation\n\n`npm install bnc-sdk`\n\n### Quick Start (Node.js)\n\n#### Transaction Monitor\n\n```javascript\nimport WebSocket from 'ws'\nimport BlocknativeSdk from 'bnc-sdk'\nimport Web3 from 'web3'\n\nconst web3 = new Web3('\u003cws://some.local-or-remote.node:8546\u003e')\n\n// create options object\nconst options = {\n  dappId: '\u003cYOUR_API_KEY\u003e',\n  networkId: 4,\n  ws: WebSocket\n  // un-comment if you would like to log all transaction events\n  // transactionHandlers: [event =\u003e console.log(event.transaction)]\n}\n\n// initialize and connect to the api\nconst blocknative = new BlocknativeSdk(options)\n\nconst txOptions = {\n  to: '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D',\n  value: 1000000000000000\n}\n\n// initiate a transaction via web3.js\nweb3.eth.sendTransaction(txOptions).on('transactionHash', hash =\u003e {\n  // call with the transaction hash of the transaction that you would like to receive status updates for\n  const { emitter } = blocknative.transaction(hash)\n\n  // listen to some events\n  emitter.on('txPool', transaction =\u003e {\n    console.log(`Sending ${transaction.value} wei to ${transaction.to}`)\n  })\n\n  emitter.on('txConfirmed', transaction =\u003e {\n    console.log('Transaction is confirmed!')\n  })\n\n  // catch every other event that occurs and log it\n  emitter.on('all', transaction =\u003e {\n    console.log(`Transaction event: ${transaction.eventCode}`)\n  })\n})\n```\n\n#### Address Listener\n\n```javascript\nimport WebSocket from 'ws'\nimport BlocknativeSdk from 'bnc-sdk'\nimport Web3 from 'web3'\n\nconst web3 = new Web3('\u003cws://some.local-or-remote.node:8546\u003e')\n\n// create options object\nconst options = {\n  dappId: '\u003cYOUR_API_KEY\u003e',\n  networkId: 4,\n  ws: WebSocket\n  // un-comment if you would like to log all transaction events\n  // transactionHandlers: [event =\u003e console.log(event.transaction)]\n}\n\n// initialize and connect to the api\nconst blocknative = new BlocknativeSdk(options)\n\nconst address = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'\n\nconst { emitter, details } = blocknative.account(address)\n\nemitter.on('all', transaction =\u003e {\n  console.log(transaction)\n})\n```\n\n### Quick Start (Browser)\n\n#### Transaction Monitor\n\n```javascript\nimport BlocknativeSdk from 'bnc-sdk'\nimport Web3 from 'web3'\n\nconst web3 = new Web3(window.ethereum)\n\n// create options object\nconst options = {\n  dappId: '\u003cYOUR_API_KEY\u003e',\n  networkId: 4\n  // un-comment if you would like to log all transaction events\n  // transactionHandlers: [event =\u003e console.log(event.transaction)]\n}\n\n// initialize and connect to the api\nconst blocknative = new BlocknativeSdk(options)\n\nconst txOptions = {\n  to: '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D',\n  value: 1000000000000000\n}\n\n// initiate a transaction via web3.js\nweb3.eth.sendTransaction(txOptions).on('transactionHash', hash =\u003e {\n  // call with the transaction hash of the transaction that you would like to receive status updates for\n  const { emitter } = blocknative.transaction(hash)\n\n  // listen to some events\n  emitter.on('txPool', transaction =\u003e {\n    console.log(`Sending ${transaction.value} wei to ${transaction.to}`)\n  })\n\n  emitter.on('txConfirmed', transaction =\u003e {\n    console.log('Transaction is confirmed!')\n  })\n\n  // catch every other event that occurs and log it\n  emitter.on('all', transaction =\u003e {\n    console.log(`Transaction event: ${transaction.eventCode}`)\n  })\n})\n```\n\n#### Transaction Preview\n\n#### Overview\n\nTransaction Preview lets you preview the outputs of any custom transactions that you submit to it. By harnessing the power of our network of Ethereum nodes, with our existing decoding and transaction lifecycle knowledge, we hope to give users of Transaction Preview even greater comfort when interacting in the Web3 space. Previewing a transaction is particularly useful for:\nWallets: Help users preview net-balance changes \u0026 identify malicious contract behavior or buggy smart contracts before interacting with them.\nDEXs \u0026 Swaps: Report accurate slippage, Accurate tokens received, and accurate failing calls\nTraders: Preview many iterations of the same trade and execute only the most profitable one\nLending Protocols: Tell whether a Borrow / Repay / Claim transaction will go through\nAuctions: Tell whether your bid or listing will go through and its accuracy \u0026 effects\nNFTs: Tell whether your NFT mint, purchase, or transfer will go through\n\u0026 much more without spending a single wei in gas!\n\n#### Supported Networks\n\nTransaction Preview is currently only supported for **Ethereum: Main**. Please stay tuned for its availability on other networks supported by Blocknative.\n\n#### Rate Limits\n\nUsage rate limit for the Transaction Preview API is 100 requests per 60-second window. Transaction Preview consumes the same daily limits on your Blocknative plan as pending simulated transactions in Simulation Platform. You can view your current consumption on your Blocknative Account Page.\n\n#### Usage\n\nThis example will mock a contract interaction between two wallets.\n\n```typescript\nimport BlocknativeSdk, { SimulationTransaction, MultiSimOutput } from 'bnc-sdk'\nimport { SimulationTransaction, MultiSimOutput } from 'bnc-sdk'\nimport { ethers } from 'ethers'\n\nconst addressFrom = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'\n\nconst CONTRACT_ADDRESS = '0x7a250d5630b4cf539739df2c5dacb4c659f2488d'\nconst erc20_interface = [\n  'function approve(address _spender, uint256 _value) public returns (bool success)',\n  'function transferFrom(address sender, address recipient, uint256 amount) external returns (bool)',\n  'function balanceOf(address owner) view returns (uint256)'\n]\n\nconst uniswapV2router_interface = [\n  'function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)'\n]\n\nconst weth = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'\nconst dai = '0x6B175474E89094C44Da98b954EedeAC495271d0F'\nlet swapTxData\nlet approveTxData\nconst createTransaction = async () =\u003e {\n  const swapContract = new ethers.Contract(\n    CONTRACT_ADDRESS,\n    uniswapV2router_interface\n  )\n  const erc20_contract = new ethers.Contract(weth, erc20_interface)\n  const oneEther = ethers.BigNumber.from('1591000000000000000000')\n  approveTxData = await erc20_contract.populateTransaction.approve(\n    CONTRACT_ADDRESS,\n    oneEther\n  )\n\n  const amountOutMin = 0\n  const amountOutMinHex = ethers.BigNumber.from(amountOutMin.toString())._hex\n\n  const path = [dai, weth]\n  const deadline = Math.floor(Date.now() / 1000) + 60 * 1 // 1 minutes from the current Unix time\n\n  const inputAmountHex = oneEther.toHexString()\n\n  swapTxData = await swapContract.populateTransaction.swapExactTokensForETH(\n    inputAmountHex,\n    amountOutMinHex,\n    path,\n    addressFrom,\n    deadline\n  )\n}\nawait createTransaction()\nconst account_address = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045'\nconst uniswapV2Router = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'\n\nconst stubTrans = [\n  {\n    from: account_address,\n    to: dai,\n    input: approveTxData.data,\n    gas: 1000000,\n    gasPrice: 48000000000,\n    value: 0\n  },\n  {\n    from: account_address,\n    to: uniswapV2Router,\n    input: swapTxData.data,\n    gas: 1000000,\n    gasPrice: 48000000000,\n    value: 0\n  }\n]\n\n// create options object\nconst options = {\n  dappId: '\u003cYOUR_API_KEY\u003e',\n  networkId: 1\n}\n\n// initialize and connect to the api\nconst blocknativeSDK = new BlocknativeSdk(options)\n\nconst singleSim: Promise\u003cSimulationTransactionOutput\u003e = blocknativeSDK.simulate(\n  'ethereum',\n  'main',\n  stubTrans[1]\n)\n\nconst multiSim: Promise\u003cMultiSimOutput\u003e = blocknativeSDK.multiSim(stubTrans)\n```\n\n#### Address Listener\n\n```javascript\nimport BlocknativeSdk from 'bnc-sdk'\nimport Web3 from 'web3'\n\nconst web3 = new Web3(window.ethereum)\n\n// create options object\nconst options = {\n  dappId: '\u003cYOUR_API_KEY\u003e',\n  networkId: 4\n  // un-comment if you would like to log all transaction events\n  // transactionHandlers: [event =\u003e console.log(event.transaction)]\n}\n\n// initialize and connect to the api\nconst blocknative = new BlocknativeSdk(options)\n\nconst address = '0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'\n\nconst { emitter, details } = blocknative.account(address)\n\nemitter.on('all', transaction =\u003e {\n  console.log(transaction)\n})\n```\n\n## Documentation\n\nFor detailed documentation head to [docs.blocknative.com](https://docs.blocknative.com/notify-sdk)\n\n## Multichain SDK (experimental new beta API that may break until it is finalized)\n\nFor apps that operate on multiple chains at once, you can use the Multichain SDK which provides a simple interface that abstracts away handling multiple WS connections at once and has a new API for subscribing to events.\n\n## Subscribing to events\n\nCurrently a transaction hash or account address can be subscribed to for all events. The `subscribe` method requires an `id`, `chainId` and a `type` and returns an `Observable`. The `Observable` that is returned is specific for events on this subscription and on completion or unsubscribing from the observable will automatically unsubscribe within the SDK. Alternatively you can listen on the global transactions `Observable` at `sdk.transactions$`.\n\n```javascript\nimport Blocknative from 'bnc-sdk'\n\nconst blocknative = Blocknative.multichain({ apiKey: '\u003cYOUR_API_KEY\u003e' })\n\n// subscribe to address events\nconst addressSubscription = blocknative.subscribe({\n  id: '0x32ee303b76B27A1cd1013DE2eA4513aceB937c72',\n  chainId: '0x1',\n  type: 'account'\n})\n\n// can listen to the address subscription directly\naddressSubscription.subscribe(transaction =\u003e console.log(transaction))\n\n// subscribe to transaction events\nconst transactionSubscription = blocknative.subscribe({\n  id: '0xbb1af436fd539a6282c6f45ed900abb5ac95ec435367f61fa8815a61bd2a7211',\n  chainId: '0x1',\n  type: 'transaction'\n})\n\n// can listen to the transaction subscription directly\ntransactionSubscription.subscribe(transaction =\u003e console.log(transaction))\n\n// or can listen for all transaction events on the global transactions$ observable\nblocknative.transaction$.subscribe(transaction =\u003e console.log(transaction))\n```\n\n## Unsubscribing\n\nTo stop listening to events on a transaction hash or account address, call the `unsubscribe` method. If called without a `chainId`, all networks will unsubscribe from the transaction or address. To only unsubscribe on a particular network, pass in the `chainId` of that network.\n\n```javascript\nblocknative.unsubscribe({\n  id: 'transactionHashOrAddress',\n  chainId: '0x1'\n})\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblocknative%2Fsdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblocknative%2Fsdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblocknative%2Fsdk/lists"}