All the existing questions explains to catch the event on client end or server. How to catch the event on smart contract itself?

Here's what I'm looking for:

  • Contract A emits the event
  • Contract B catched the event and stores the params.
  • Both of these contracts have different address.
  • What would be the point to have this kind of pubsub functionality in the smart contract itself rather than calling directly a function of B? May 11, 2018 at 7:13

1 Answer 1


Contracts cannot watch each other's events. Events are for the outside world, like web3.

You can, however, implement the functionality yourself. It won't be cheap to run it, though.

A (incomplete and very insecure, but you'll get the idea) example:

pragma solidity 0.4.23;

interface EventHandler {
    function handleEvent(uint256 value) external;
// A
contract EventEmitter {

    EventHandler[] public eventHandlers;

    function emitEvent(uint256 _value) public {
        for(uint256 i = 0; i < eventHandlers.length; i++){

    function registerHandler(EventHandler _handler) public {
        // Push handler

// B
contract SomeContract is EventHandler {
    uint256 public value;

    constructor(EventEmitter _emitter) public {

    function handleEvent(uint256 _value) external {
        value = _value;
        emit ValueSet(_value);

    event ValueSet(uint256 value);


First, deploy the EventEmitter. Then, use it's address to instantiate a couple of SomeContracts. When you call EventEmitter.emitEvent, you'll see that the SomeContracts react to that

Not the answer you're looking for? Browse other questions tagged or ask your own question.