contract B {
    event eventFallback();

contract A {
    address contractB;

    function () public payable {
         emit B(contractB).eventFallback();

I tried like above and failed. Is there a way to emit an event in another contract? (except creating an interface function like below.)

function emitEvent() public {
    emit eventFallback();

You can not directly emit an event from another contract. The only way to do it is by wrapping the emit into a function (like you described above).

From the perspective of modularity, the point at which an event is emitted, should be in the control of the emitting contract. Everything else would be fragile, since the contract could not make any stable promisses about its interface.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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