3

I have an API (expressjs - nodejs) listening for different events from my contract.

var web3 = new Web3(new Web3.providers.WebsocketProvider("ws://localhost:8546"));
var tokenContract = new web3.eth.Contract(tokenAbi, URL.tokenAddress);

tokenContract.events.EventTest({
    fromBlock: 'latest'
}, function (err, event) {
   console.log('event triggered');
});

For this, I need a provider. When I'm using parity:

parity --chain ropsten

Everything works fine.

But when I try with Geth, I NEVER received events from my contract:

geth --testnet --ws --wsport=8546 --wsorigins="*"

I'm well connected to the network because :

web3.eth.net.getId().then(function (id) {
     console.log('ID network chain', id);
});

Return me the id 3.

Do I miss something? Thank you in advance.

Your Answer

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

Browse other questions tagged or ask your own question.