Hot answers tagged

2

Let me elaborate a bit on the valid answer from @pbsh. As mentioned, they behave quite differently and are for different use case. Events can't be monitored by other smart contracts, only by external systems monitoring the blockchain (and the specific contract). Partially the opposite is true for return values. What I mean by 'partially' is that an external ...


1

When you return data from a function, the return value can be accessed only if you know the transaction hash in which the function was called. This is because the return value is scoped to that particular transaction. However, you can set up a listener that can be always listening to certain events. And if you want to get all the events emitted by the ...


1

For future users, make sure to copy the abi from etherscan/polygonscan as an object. While the above example might work, this time it caused the event to not get called without any errors.


1

When you use this keyword inside a function callback, the scope of this is the function itself. Something like this should work as the scope of this won't conflict inside the callback. listenToMyEvent = async () => { const { accounts, contract } = this.state; const getSuccessCount = this.getSuccessCount; async function eventCallback(event)...


1

Neither of them were popular enough at the time they were released. This is why they were not built to be compatible. Also there were no standards available at the time, so nobody had a specific direction to build towards. Of course ERC-721 fixed the standards part. And general awareness of the new techniques is fixing new projects to come.


1

Did you try using eth_getLogs. This is also exposed via the Ethers provider: https://docs.ethers.io/v5/api/providers/provider/#Provider-getLogs. The syntax for the parameter is the same as for eth_newFilter.


1

You get that because of fromBlock: 0. Its telling you that your 'plan' only allows to retrieve 1000 blocks but from 0 to latest is more than 1000. I was confused too.. perhaps Polygon have different plans for different types of users or something. I couldnt find any documentation on this. What I did was get the current block using web3.eth.getBlockNumber, ...


Only top voted, non community-wiki answers of a minimum length are eligible