-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Watching contract events with Infura #73
Comments
We support websocket endpoints on mainnet, ropsten and rinkeby now that allow you to listen to events:
The alternative would be to call eth_getLogs starting at a block that's relevant to the contract. |
@ncocchiaro , would you please explain more details how to watch contract events? |
I am using Infura to mint tokens, but I am not able to find a way to confirm whether transaction is succeeded or failed.
Error: Web3ProviderEngine does not support synchronous requests. Please let me know how to watch events when using infura, thank you so much. |
@StarNeit an example of how to use Pub/Sub via websockets to listen for new blocks can be found in #29 (which as it seems you've found by now) and I'm pasting it below. You should be able to adapt that for logs, following the geth pub/sub documentation at https://github.com/ethereum/go-ethereum/wiki/RPC-PUB-SUB.
The other issue with Web3ProviderEngine is unrelated and due to Web3 not returning promises, so you're effectively calling a method synchronously, which is disallowed. |
@ncocchiaro , Thank you for your kind explanation. |
@ncocchiaro , Thank you. I solved problem by using getTransactionReceipt. 👍 👍 👍 |
Great, let us know if you have other issues. |
@StarNeit can you please tell me how did you solve by getTransactionReceipt? |
@ncocchiaro is kovan |
We plan on adding support for the Parity pub/sub interface (all the existing websocket endpoints are backed by Geth), at that point it's possible we'll add a Kovan endpoint. In the meantime if you require a PoA network and don't strictly require Parity my suggestion is to try Rinkeby. |
Thanks for the update. One more question, it seems the websocket interface doesn't implement non pub/pub methodes (like getBlock()...) I suppose it's by design ? |
I'm trying to use:
But I'm getting the following error:
As per the documentation: https://web3js.readthedocs.io/en/1.0/web3-eth-subscribe.html#subscribe
Can I pass an Array of addresses instead of a single address? |
If you want to watch contract events, use this API: http://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#contract-events
|
Hey @ncocchiaro ! Long time no see :D Is there still no support for a truffle-kovan endpoint from infura?! Thanks man, hope you have been well~ |
Hey @tcsiwula, we have the RPC endpoint at https://kovan.infura.io/YOUR_API_KEY but not yet a websockets endpoint for Kovan. |
I am having the same issue, the problem is i cannot use Websockets as I am using web3 0.20.6, as when i use web3 1.0 my constant function gives me the error "UnhandledPromiseRejectionWarning: Error: Couldn't decode uint256 from ABI: 0x" when using infura. Since i was not able to resolve the issue with constant functions when using infura so i switched to web3 0.20.6 which works fine for everything except events. Both events and Constant functions works fine if i use ganache but as soon as i connect to infura every thing breaks down. Please tell me how can i watch or get events using infura and web3 v 0.20.6? |
Micro rant in a related issue: #13 (comment) Now realizing I need to update my web3.js, Trying to set up super basic demo using Sample code:
|
yep i got the same error , i am asking the same question on gitter channel. |
Have you fixed this problem ? |
Yes I did downgrades Yk beta version 33 and solved the problem |
i got the same error, what is Yk you refers to? @acidfreako |
the problem/fix(?) is described here: web3/web3.js#1559 |
@wodxumingxu yes downgrading the web3 from beta 34 to 33 helped |
@ncocchiaro Can you already tell when there will be support for websockets on Kovan? |
Good timing! We now have a wss://kovan.infura.io/ws endpoint, and have just published new documentation on the websocket API: https://infura.io/docs/wss/introduction. Please create a new issue if you see any problems. |
Issue #13 shared the inability to listen to contract events through JSON-RPC calls using Infura a year ago. Does any team member have a suggestion on how to achieve so currently? Thank you so much.
The text was updated successfully, but these errors were encountered: