Solidity syntax error - SENT

I learn Solidity from the official documentation and the stack in the exercise, where I create a simple coin:

pragma solidity ^0.4.20; // should actually be 0.4.21

   contract Coin {
    // The keyword "public" makes those variables
    // readable from outside.
    address public minter;
    mapping (address => uint) public balances;

    // Events allow light clients to react on
    // changes efficiently.
    event Sent(address from, address to, uint amount);

    // This is the constructor whose code is
    // run only when the contract is created.
    function Coin() public {
        minter = msg.sender;
    }

    function mint(address receiver, uint amount) public {
        if (msg.sender != minter) return;
        balances[receiver] += amount;
    }

    function send(address receiver, uint amount) public {
        if (balances[msg.sender] < amount) return;
        balances[msg.sender] -= amount;
        balances[receiver] += amount;
        emit Sent(msg.sender, receiver, amount);
    }
}

When I try to compile, I received a syntax error in the last line:   emit Sent (msg.sender, receiver, quantity)

I tried to compile it in Remix and VS Code, but got the same error message.

Can someone help me pls?

+4
source share
1 answer

The keyword emitwas added in Solidity 0.4.21. Prior to this version, you generate events using only the event name.

Sent(msg.sender, receiver, amount);

You can view the offer here .

+1
source

Source: https://habr.com/ru/post/1694104/


All Articles