Ethereum / Solidity receives smartcontract events in geth console

So I tried to get events generated by my smartcontract

var abi = [{
  "constant": false,
  "inputs": [{
    "name": "_value",
    "type": "int32"
  }],
  "name": "changeLowerTrigger",
  "outputs": [],
  "payable": false,
  "type": "function"
}, {
  "constant": true,
  "inputs": [],
  "name": "metric",
  "outputs": [{
    "name": "name",
    "type": "string",
    "value": "place_holder_metric_name_to_be_autogenerated"
  }, {
    "name": "value",
    "type": "int32",
    "value": "7"
  }],
  "payable": false,
  "type": "function"
}, {
  "constant": false,
  "inputs": [{
    "name": "_value",
    "type": "int32"
  }],
  "name": "changeUpperTrigger",
  "outputs": [],
  "payable": false,
  "type": "function"
}, {
  "constant": false,
  "inputs": [{
    "name": "_value",
    "type": "int32"
  }],
  "name": "update",
  "outputs": [],
  "payable": false,
  "type": "function"
}, {
  "anonymous": false,
  "inputs": [{
    "indexed": false,
    "name": "_value",
    "type": "int32"
  }],
  "name": "ValueChanged",
  "type": "event"
}, {
  "anonymous": false,
  "inputs": [{
    "indexed": false,
    "name": "_alarm",
    "type": "string"
  }, {
    "indexed": false,
    "name": "_value",
    "type": "int32"
  }],
  "name": "Alarm",
  "type": "event"
}]
var MyContract = web3.eth.contract(abi);

var myContractInstance = MyContract.at(
  '0x3B03c46Dfc878FeF9fAe8de4E32a6718f2E250e9');

var events = myContractInstance.allEvents();

// watch for changes
events.watch(function(error, event) {
  if (!error)
    console.log(event);
});

// Or pass a callback to start watching immediately
var events = myContractInstance.allEvents(function(error, log) {
  console.log(err, log);
});
      

Run codeHide result


But it only returns:

> events
{
  callbacks: [function(error, log)],
  filterId: "0xd6af6f5a7273fe21452f00c4682456",
  getLogsCallbacks: [],
  implementation: {
    getLogs: function(),
    newFilter: function(),
    poll: function(),
    uninstallFilter: function()
  },
  options: {
    address: "0x3B03c46Dfc878FeF9fAe8de4E32a6718f2E250e9",
    from: undefined,
    fromBlock: undefined,
    to: undefined,
    toBlock: undefined,
    topics: []
  },
  pollFilters: [],
  requestManager: {
    polls: {
      0xd6af6f5a7273fe21452f00c4682456: {
        data: {...},
        id: "0xd6af6f5a7273fe21452f00c4682456",
        callback: function(error, messages),
        uninstall: function()
      }
    },
    provider: {
      newAccount: function(),
      send: function github.com/ethereum/go-ethereum/console.(*bridge).Send-fm(),
      sendAsync: function github.com/ethereum/go-ethereum/console.(*bridge).Send-fm(),
      sign: function(),
      unlockAccount: function()
    },
    timeout: {},
    poll: function(),
    reset: function(keepIsSyncing),
    send: function(data),
    sendAsync: function(data, callback),
    sendBatch: function(data, callback),
    setProvider: function(p),
    startPolling: function(data, pollId, callback, uninstall),
    stopPolling: function(pollId)
  },
  formatter: function(),
  get: function(callback),
  stopWatching: function(callback),
  watch: function(callback)
}
      

Run codeHide result


But what I want is the events shown in the following image at the very bottom (for example, Value Changed: 7): enter image description here

Since events are displayed in the ETH Wallet, there must be a way. I just want to get the latest events in the geth (or sth similare) console. Thanks for any help I have lost a bit and have the worst lifestyle of my life.

+3


source to share





All Articles