1

I want to view event log history in my html screen. But I am getting below error in console. Can any one please look into this. I am new in blockchain and this is the first blockchain code I am executing. Not sure where it got stuck.

Error Log:

app_device.js:109 Error: Gateway timeout. The request took too long to process. This can happen when querying logs over too wide a block range.
    at Object.InvalidResponse (inpage.js:8198)
    at inpage.js:8198
    at inpage.js:174
    at inpage.js:8175

HTML File

<button id="handleAllMintCoinEventButton" onclick='handleAllMintCoinEvent()'> <label id="buttonTexthandleAllMintCoinEvent">Fetch All Events</label</button>
         </div>
         <label id="MintCoinEvents"></label>

JS File:

function handleAllMintCoinEvent(){
    var AddForFetchinEvents = document.getElementById('AddForFetchinEvents').value;

    //var allEvents = myContractInstance.CoinMinted({to:AddForFetchinEvents},{fromBlock: 0, toBlock: 'latest'},function(error, result) {
    if(AddForFetchinEvents!=''){    
    console.log(AddForFetchinEvents);
    var allEvents = myContractInstance.Sent({from:AddForFetchinEvents},{fromBlock: 0, toBlock: 'latest'},function(error, result) {
              if (!error) {
                  //var msg = result.args.to +" received " + (result.args.amount) + " fresh new coins " ;
                    document.getElementById('MintCoinEvents').innerHTML += "<hr/>"+result;
//                  op.push(msg)
                    console.log(result);
              }
              else {
                  console.error(error);
              } 
        }); 
    } else {
        console.log("pulling all the events");
        var allEvents = myContractInstance.Sent({},{fromBlock: 1577465, toBlock: 1577565},function(error, result) {
              if (!error) {
                  //var msg = result.args.to +" received " + (result.args.amount) + " fresh new coins " ;
                    document.getElementById('MintCoinEvents').innerHTML += "<hr/>"+result;
//                  op.push(msg)
                    console.log(result);
              }
              else {
                  console.error(error);
              } 
        }); 
    }
    allEvents.stopWatching();

}

Sol file:

event Sent(address indexed from, address indexed to, uint indexed deviceCode,string deviceType,string deviceDesc,string devManDate,string devManCompany,uint256 deviceCost,string remarks);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.