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="*"

1 Answer 1


Here is what works for me:

geth --testnet --ws --wsaddr --wsport 8546 --wsorigins * --cache 512 --rpc --wsapi "eth,net,web3,network,debug,txpool" --rpcapi "eth,net,web3,network,debug,txpool" --rpcaddr --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 and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.