Already referred web3 documentations and other Q-A for web socket connection. Currently using infura as provider.
3
-
Please mark the question as solved if I helped you – Niklas Feurstein Aug 30 '19 at 14:50
-
Do you need further guidance or is this question completed? – Niklas Feurstein Sep 2 '19 at 15:12
-
@NiklasFeurstein, further discussion available at Discussion Room. – Rudrika Sep 3 '19 at 5:42
Add a comment
|
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 = 'yourContractAddress';
const contract = new web3.eth.Contract(abi, address);
contract.getPastEvents('allEvents', {
fromBlock: 0,
toBlock: 'latest'
}).then(function(events){
console.log(events);
});
Replace the variables. Take note of the URL. Websocket URL is not only different by wss
at the front.
This code is tested and surely works.
EDIT: Please write why you downvote this answer! It is completely correct.
-
-
Every time it returns, connection not open on send() Error: connection not open – Rudrika Aug 30 '19 at 10:03
-
Check if your node or ganache-cli process listening at the endpoint provided is up – Sanjay S B Aug 30 '19 at 11:21
-
-