When I am calling this code(it's a test code related to the bigger contract, but the same problem can be observed here) I am receiving an error - ParserError - expected ';' but got '.' .

pragma solidity ^0.6.12;

import "./TRC20.sol";

contract Contract1 is ITRC20{
    address token;
    function emitter() {
        emit  ITRC20(token).Transfer(msg.sender, msg.sender, 25);

why can't I emit an event this way? Thanks.


Events are different from functions, you can only emit events of your own contract, there's no way to emit events of another contract.

ITRC20(token) is basically another contract at the token address, you can access its public functions with something like ITRC20(token).transfer(msg.sender, 25), but you cannot access the Transfer event of that contract with the dot operator, thus the compiler does not expect to see that dot operator in the emit statement.

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.