Hacker News new | ask | show | jobs
by coryl 3124 days ago
I've also just begun to play with smart contract programming.

One problem I'm having is with event listening.

It seems that MetaMask doesn't yet support subscriptions, nor does my localhost testRPC instance pass it in the web3 object.

Some have suggested I need to run my own node just to listen for contract events. Has anyone figured out an easier solution?

3 comments

Possibly because the latest version of MetaMask has broken event listening: https://github.com/MetaMask/metamask-extension/issues/2393
Quick question, do you have to download the full ethereum chain before you can start messing with smart contracts? Or is there a "light" client you can use?
You shouldn't use the main ethereum network when testing smart contracts - develop on a local testnet and then if you want, on a public testnet (eg rinkeby or ropesten) first
You can use a test node called testrpc (now called ganache-cli ???) and connect to that.
I've had success listening to events using web3, against both testrpc and geth (on private and test networks). What version of web3 & testrpc are you using?
I'm using web3 1.0.0-beta.26, ganache-cli 6.0.3

I instantiate the web3 object as such: web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));

When I try to setup an event listener, console logs this:

Error: The current provider doesn't support subscriptions: HttpProvider