2

is there a way to view all events on all blocks for Eris Blockchain? Currently I've managed to just subscribe a particular event

Contract

contract IdisContractsFTW {
  uint storedData;
  string name;

  event SetName(address indexed _from, string _name);

  function set(uint x) {
    storedData = x;
  }

  function get() constant returns (uint retVal) {
    return storedData;
  }

  function setName(string _name){
    name = _name;
    SetName(msg.sender, _name);
  }

  function getName() constant returns (string retVal){
    return name;
  }

}

Node.js

var myContract;

var IdisContractsFTW = JSON.parse(fs.readFileSync('./abi/' + 'IdisContractsFTW', 'utf8'));
var myContractFactory = manager.newContractFactory(IdisContractsFTW);


myContractFactory.at(incoming.address, function(error, contract){
    if(error) {throw error}
    myContract = contract;

    if(myContract){

        myContract.SetName(
            function(error,eventSub){
            if(error){
                throw error;
            }
            if(eventSub){
                console.log(JSON.stringify(eventSub));
                response.statusCode = 200;
                response.setHeader('Content-Type', 'application/json');
                response.write(JSON.stringify(eventSub));
                response.end('\n');
            }


        }, function (error,event) {
                if(error){
                    console.log("listenContractEvent error:"+error);
                }
                if(event){
                    console.log("event:"+JSON.stringify(event));
                }

            }
        );



    }

});

My current code in node.js just prints out an event whenever it's created. I'm trying to get an array of events ever created by this contract IdisContractFTW. Appreciate your advice on this one.

The manager object here is created using

var contracts = require('eris-contracts');
manager = contracts.newContractManagerDev(chainUrl, accounts.simplechain_full_000);

This is a repost of a question i've asked in stackoverflow. but I didn't manage to get an answer there https://stackoverflow.com/questions/39981393/is-there-a-way-to-view-all-events-on-all-blocks-for-eris-blockchain

  • Please do not crosspost questions across multiple sites of the stack exchange network. – Afr Nov 2 '16 at 10:25
2

This is not possible today but it's a commonly requested feature.

| improve this answer | |

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.