So far, I'm trying to get transactions list using web3 & infura by websocket provider.

Here is my code

const Web3 = require("web3");

const web3 = new Web3(new Web3.providers.WebsocketProvider('wss://mainnet.infura.io/ws/v3/YOUR_PROJECT_ID'));

let subscription = web3.eth.subscribe('logs',{'address':'ANY_ADDRESS','fromBlock':7244886})
subscription.subscribe((error, result) => {
    if (error) throw error;
.on('data',async (txns) => {

However, I'm getting response successfully. But before receiving transactions, there is a warning arrives like below

(node:5382) UnhandledPromiseRejectionWarning: TypeError: callback is not a function
    at /var/www/html/test/node_modules/web3/node_modules/web3-core-subscriptions/dist/web3-core-subscriptions.cjs.js:119:11
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:5382) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:5382) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

web3 version (npm list web3) - web3@1.0.0-beta.46

web3-core-subscriptions version (npm list web3-core-subscriptions) -

+-- web3-core-subscriptions@1.0.0-beta.46 
+-- web3-eth@1.0.0-beta.36
| +-- web3-core-method@1.0.0-beta.36
| | `-- web3-core-subscriptions@1.0.0-beta.36  extraneous
| +-- web3-core-subscriptions@1.0.0-beta.36  extraneous
| `-- web3-eth-contract@1.0.0-beta.36
|   `-- web3-core-subscriptions@1.0.0-beta.36  extraneous
`-- web3-shh@1.0.0-beta.36
  `-- web3-core-subscriptions@1.0.0-beta.36  extraneous

You should update web3 to a later beta version: https://github.com/ethereum/web3.js/issues/2364. This was fixed post 46.

  • I tried with npm install web3@latest but it still installs web3@1.0.0-beta.46 version.
    – Deepak M
    Feb 21 '19 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.