27 votes
Accepted

How to listen to contract events using ethers.js?

This answer assumes that you understand how to connect to a contract using Ethers. Your question specifies listening for an event to be emitted, and to do a task based on that. Here is the link to the ...
user avatar
22 votes
Accepted

Geth can't connected to via Websocket

At a guess, it's because of this: --ws.origins value Origins from which to accept websockets requests I encountered the same 403 error, added --ws.origins="*", and was able to connect. ...
user avatar
15 votes

How to listen to contract events using ethers.js?

// event in ERC-20: Transfer(address indexed src, address indexed dst, uint val) contract.on("Transfer", (to, amount, from) => { console.log(to, amount, from); }); You can read ...
user avatar
  • 711
5 votes

Geth can't connected to via Websocket

Below is an answer for errors when connecting from web3.js WebsocketProvider. Short Answer If there is client's host noted inside origin '<...>' in message, just specify it with geth as geth --...
user avatar
  • 505
5 votes

web3 Websocket connection to infura

was fixed on web3@1.0.0-beta.36 https://github.com/ethereum/web3.js/issues/1559#issuecomment-412348642
user avatar
4 votes
Accepted

How to apply EthFilter to specific address?

OK, let's say you have a smart contract deployed on the address CONTRACT_ADDRESS which can trigger different type of events Event definitions: event GameStarted(bytes32 indexed gameId, address ...
user avatar
4 votes

web3 Websocket connection to infura

This is working #!/usr/bin/env node const Web3 = require('web3'); const web3 = new Web3(new Web3.providers.WebsocketProvider('wss://mainnet.infura.io/ws')); const subscription = web3.eth.subscribe('...
user avatar
3 votes

web3 Websocket connection to infura

It seems a value of WebSocket request header is invalid. More specifically say, a value of Sec-WebSocket-Protocol is undefined. According to the github issue below, the issue was introduced from ...
user avatar
3 votes
Accepted

Is there a max number of websocket connections that geth can support?

1 million, or maybe 2 million, all depends on your hardware. This is not a question about Ethereum , but more about: golang.org/x/net/websocket which is what go-ethereum uses
user avatar
  • 3,436
3 votes

How to connect with WebSocket with Web3?

I think this is what you are looking for: const Web3 = require('web3'); const web3 = new Web3('wss://ropsten.infura.io/ws/v3/<yourID>'); const abi = "placeYourABI"; const address = '...
user avatar
3 votes
Accepted

Is there a way to listen to log events via websocket with web3py

Web3.py doesn't offer methods to subscribe automatically so we have to manually listen to the websocket and use rpc methods to send the subscription to logs : import asyncio import json from web3 ...
user avatar
2 votes

TypeError: Web3.providers.WebsocketProvider is not a constructor?

I had the same issue with web3 v1.0.0 beta 30. Never got to the bottom of it but skipping the provider construction appeared to fix it: var Web3=require('web3'); var web3 = new Web3('ws://10.244.5.43:...
user avatar
  • 2,247
2 votes

How to expose the underlying web socket connection from the WebSocketProvider?

Let me answer each of your questions: 1. At what point is the connection actually made The connection is actually made after creating a WebsocketProvider object. Taking a snippet from your example: ...
user avatar
2 votes

web3 websocket connection prevents node process from exiting

WebSockets provide a persistent connection between a client and server. This connection has to be manually closed, otherwise the library tries to keep the connection alive. It feels funny to me ...
user avatar
2 votes

Subscription using websocket through Geth

Eventually, I developed a proof-of-concept. I posted the source in GitHub at https://github.com/AlanL1/Ethereum-FrontEnd The code that might be useful to you is in transaction.html. I use ...
user avatar
2 votes

Subscribe to events using local geth in light mode?

No, my suggestion was wrong, the problem is different. I did the same steps, but with web3.js and it worked out. UPD: So, after updating the go package go-ethereum to v1.9.2, everything works ...
user avatar
2 votes

Is there a websocket URL in Ethereum classic like in Ethereum?

Short answer: no idea. It's not a functionality of the blockchain protocol. It's a functionality in the client nodes. So the Ethereum itself doesn't care how people interact with it, as long as the ...
user avatar
2 votes

405 Method Not Allowed with websocket geth RPC

OK, the issue is that several guides on how to connect to websockets using Curl don't work on geth's websocket for whatever reason. Using a tool specifically for websockets allowed the requests to go ...
user avatar
  • 122
1 vote

Infura Web Sockets doesn't work on Infura

According to this, the web3 provider URL should look something like: wss://ropsten.infura.io/ws/v3/YOUR-PROJECT-ID
user avatar
  • 79
1 vote
Accepted

geth event newPendingTransactions does not occur

The problem was that I did not wait for the end of synchronization. I started from scratch (this time i used Rinkeby network): geth --rinkeby --verbosity 3 --syncmode fast --ipcdisable --ws --wsapi "...
user avatar
1 vote

Having issue with Infura mainnet web3 connection and getting info

web3.eth.getBalance(address) returns a promise which will only either return an error or the balance once the transaction is mined. function getBalance(){ var balance; web3.eth.getBalance(...
user avatar
  • 332
1 vote

Connecting to blockchain on azure using web3.js and websocket

If you are using azure POA consortium you have already a websocket endpoint. The url is available under deploiment outputs as shown in the picture below ::
user avatar
  • 17.6k
1 vote
Accepted

TypeError: Cannot set property 'method' of undefined when using WebsocketProvider

Make sure you have ganache-cli@beta installed You have to hack around the send and sendAsync issue when setting provider. so: export const setProvider = (provider: any) => Contracts.concat(...
user avatar
1 vote

TypeError: Cannot set property 'method' of undefined when using WebsocketProvider

Are you aware that the API for RPC and WS is different? Not sure if ganache supports this, with the "normal" geth you need to start it like geth --ws. That will bind the websocket API to port 8546 per ...
user avatar
1 vote

"Connection not open" error when subscribing to address with websocket

Try this : geth --ws --wsaddr "0.0.0.0" --wsapi "eth,net,web3,admin,shh" --wsorigins "*" --mine --minerthreads=1 --datadir ./test/testDataDir/ --networkid 15
user avatar
  • 352
1 vote

Get a large amount of blocks with web3 (nodejs)

Sorry for the self-promotion, but you can use QuickBlocks to do the same thing much more effectively because it will additionally cache the blocks locally so that the next time you do the same (or ...
user avatar
1 vote

Is there any websocket ethereum provider?

Use Infura.io to connect to different blockchains. You will need an account and project id. Steps to create an Infura.io Project and remarks 1) Open Infura.io page and sign up for an account. On ...
user avatar
1 vote

Is there any websocket ethereum provider?

QuikNode.io offers dedicated ETH nodes with https:// and wss:// endpoints.
user avatar
  • 79
1 vote

Is there any websocket ethereum provider?

Infura! wss://mainnet.infura.io/ws wss://ropsten.infura.io/ws wss://rinkeby.infura.io/ws
user avatar
1 vote

Unable to connect to geth

you can use this sample code: if(type of web3 !== 'undefined'){ // Use injected web3 by Metamask/Mist window.web3js = new Web3(web3.currentProvider); } else { // ...
user avatar
  • 664

Only top scored, non community-wiki answers of a minimum length are eligible