1

what are the optimal geth settings if you just want to listen to some events that are fired by smart contracts?

I'm having a bit trouble to setup geth properly.

Thanks a lot.

PS: That is my current setup:

geth --cache=1024 --syncmode=fast --rpc --rpcapi "eth,web3,personal,net,network,debug,txpool" --ws --wsorigins="*"
0

Here is what works for me:

geth --testnet --ws --wsaddr 0.0.0.0 --wsport 8546 --wsorigins * --cache 512 --rpc --wsapi "eth,net,web3,network,debug,txpool" --rpcapi "eth,net,web3,network,debug,txpool" --rpcaddr 0.0.0.0 --rpcport 8545 --fast

It's listening both on rpc and ws, but you can only use ws if you want.

Then, there are two things to know about listening to events with web3 1.0:

  1. Event subscription won't show past events. If you need past events, use this:

    YourContract.getPastEvents('YourEventName', { fromBlock: 0 }, (error, events) => {})

  2. You can listen for new events like this:

    TokenContract .events .Transfer({ from: 0, to: 'latest', }) .on('data', event => console.log('data', event));

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.