1

I am trying to connect to Kovan testnet from a Node.js server. I have tried to connect in order to retrieve past events.
Steps tried so far:-
The connection was done via Infura. Tried these steps over multiple versions

Version 0.20.3(Version in Github):

var MyContract = web3.eth.contract(JSON);

contractAddress=<contractAddress>;
var contractInstance = MyContract.at(contractAddress);
var events = contractInstance.allEvents({fromBlock: 5000000, toBlock: 'latest'});

events.get(function(error, logs){
    console.log(logs);
});

Despite having events no output are produced. If Infura is the issue is there any other way I can get events from Kovan Testnet?

I tried web3-1.0.0.beta19 to connect to Infura via websockets but realised there are no websockets for Kovan.

0

I found a work around by using the zero client provider. It works in a stable manner for the Mainnet and Kovan RPC connections provided by Infura.

0

while starting parity with --chain=kovan to connect to kovan testnet use the additional options of pubsub,parity,parity_pubsub in --ws-apis and also add --jsonrpcapis=all option.

if you start parity with the above options you will be able to register for contract events using contractInstance.events.MyEvents() in your nodejs javascript code.

my nodejs application which worked perfectly while running on local ethereum node had trouble in capturing contract events while moving to kovan testnet. I was able to resolve the issue with the above options.

Copying the complete command which worked for me below.

parity --chain=kovan   --ws-apis="eth,net,web3,personal,web3,pubsub,parity,parity_pubsub" --rpcapi="eth,net,web3,personal" --jsonrpc-apis=all

Hope it helps.

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.