In pub-sub scenario there can be a need when one contract would like to notify all listeners about some fact. It may also contain enough ethers for gas as listeners, during registration, sends some up front.

Can one smart contract easily call (notify) all registered listeners? Or are there some limitations or maybe even that kind of behaviour is impossible in Ethereum's smart contracts?


Every contract your interact with will cost gas (which costs ether), and I am unaware of any scheme under which these costs would not rise linearly with the number of subscribers.

Each time you execute another contract you will be looking at a baseline of 21,000 gas plus whatever gas the actual execution requires. In perfectly optimal conditions, your upper limit for number of contracts that you could call in a single transaction is going to be blockGasLimit / 21000 which currently works out to approximately 225 calls.

I would assume any such service applied generically will likely need to ensure that gas costs are paid by the subscribers. In this case, you probably want something akin to this proof of concept contract.


This gas proxy is guaranteed to repay the caller all gas costs. With some access control in place to ensure that the contract is only called in appropriate conditions this type of contract could be used to keep the costs for gas on the subscriber's side.

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.