My event call is
event AmountChanged(address indexed purchaser, uint256 value);
My function in solidity
function () external payable {
uint256 amountinwei = msg.value;
AmountChanged(msg.sender, msg.value);
}
When i am calling it through web3
contractinstance.AmountChanged({}, {fromBlock: 0, toBlock: 'latest'}).watch(function(err, result){
console.log(result);
console.log(err);
});
I am getting error ----
Error: Invalid JSON RPC response: ""
at Object.InvalidResponse (/Volumes/Macintosh HD 2 2/MorpheusApiGit/WebServices/Node-API-Morpho/node_modules/web3/lib/web3/errors.js:38:16)
at XMLHttpRequest.request.onreadystatechange (/Volumes/Macintosh HD 2 2/MorpheusApiGit/WebServices/Node-API-Morpho/node_modules/web3/lib/web3/httpprovider.js:115:32)
at XMLHttpRequestEventTarget.dispatchEvent (/Volumes/Macintosh HD 2 2/MorpheusApiGit/WebServices/Node-API-Morpho/node_modules/xhr2/lib/xhr2.js:64:18)
at XMLHttpRequest._setReadyState (/Volumes/Macintosh HD 2 2/MorpheusApiGit/WebServices/Node-API-Morpho/node_modules/xhr2/lib/xhr2.js:354:12)
at XMLHttpRequest._onHttpResponseEnd (/Volumes/Macintosh HD 2 2/MorpheusApiGit/WebServices/Node-API-Morpho/node_modules/xhr2/lib/xhr2.js:509:12)
at IncomingMessage.<anonymous> (/Volumes/Macintosh HD2 2/MorpheusApiGit/WebServices/Node-API-Morpho/node_modules/xhr2/lib/xhr2.js:469:24)
at IncomingMessage.emit (events.js:164:20)
at endReadableNT (_stream_readable.js:1054:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
using web3@0.19.1 web3.providers.HttpProvider("https://rinkeby.infura.io/")
Thanks in advanced
Also, when we go live does main net of infura support http-based API ???
– Muddassar Shaikh Feb 09 '18 at 09:05However when we go live on the client side when we use web3, we would like to connect to mainnet without downloading it, thats why we choose infura.
Can you please guide us, how to test this on rinkeby and which provider to use when we go live.....
Thanks for your support
– Muddassar Shaikh Feb 09 '18 at 09:44So, which web3 provider should we use on mainnet as event dont work with infura??
Also, how contract are deployed on main net
– Muddassar Shaikh Feb 09 '18 at 09:51