0

I'm using Solidity events to interact with my html page, once a change is done in the contract or page the watch function from html reflects back to the contract.

My question here is, while checking the contract I only see the last data record not all of the events captured thus how can I see the events captured by my contract can this be done via Remix? Else how is it done?

I'm using the below code as well, need help in viewing all of the submitted data.

function commitTask(int256 _temp, string memory _location, string memory _time) public inState(State.Created) payable
{

    //require(dataCount <= rewardNum);
    require (keccak256(abi.encodePacked(location)) == keccak256(abi.encodePacked(_location)), "Wrong location.");
    require(_temp < 35 && _temp > -5, "Temperature out of range");
    dataCount += 1;
    if(dataCount == rewardNum)
    {
        msg.sender.transfer(reward);
        emit TaskDone();
    }

    emit DataCommited( _temp, _location, _time);
0

If you are using ContractInstance.events.allEvents() there is a parameter 'fromBlock' which defaults to 'LatestBlock', so to get older events you should set a block number as a start point

  • Its there a way to display all the submitted values? Since if I'm using the client side html page wont be able to know all of the block numbers. – user51821 Aug 4 at 13:08
  • I'm using the below code to commit my task and event commit, just need to display all of the committed data I've added my code in the question. – user51821 Aug 4 at 13:09
  • if fromBlock is 0 - you get all events, but it takes more time – KNK Aug 4 at 13:50
  • Where can I run this command, and could you kindly give me an example? Much be great help. – user51821 Aug 5 at 6:39
  • It's a web3js function call and there are some differnces between 0.2x and 1.x. Check the docs at web3js.readthedocs.io/en/v1.2.0/web3-eth-contract.html or ethereum.stackexchange.com/questions/55529/… for an example – KNK Aug 5 at 16:02

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.