function() public payable{


pragma solidity ^0.5.0;

import "./EIP20Interface.sol";

contract InitialTokenOfferingIncomeFAIR is EIP20Interface {

    uint256 constant private MAX_UINT256 = 2**256 - 1;
    mapping (address => uint256) public balances;
    mapping (address => mapping (address => uint256)) public allowed;

    string public name;
    uint8 public decimals;
    string public symbol;

    uint price = 0.1 ether;

    function ito(
        uint256 _initialAmount,
        string memory _tokenName,
        uint8 _decimalUnits,
        string memory _tokenSymbol
    ) public {
        balances[msg.sender] = _initialAmount;
        totalSupply = _initialAmount;
        name = _tokenName;
        decimals = _decimalUnits;
        symbol = _tokenSymbol;

    function transfer(address _to, uint256 _value) public returns (bool success) {
        require(balances[msg.sender] >= _value);
        balances[msg.sender] -= _value;
        balances[_to] += _value;
        emit Transfer(msg.sender, _to, _value);
        return true;

    function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
        uint256 allowance = allowed[_from][msg.sender];
        require(balances[_from] >= _value && allowance >= _value);
        balances[_to] += _value;
        balances[_from] -= _value;
        if (allowance < MAX_UINT256) {
            allowed[_from][msg.sender] -= _value;
        emit Transfer(_from, _to, _value);
        return true;

    function balanceOf(address _owner) public view returns (uint256 balance) {
        return balances[_owner];

    function approve(address _spender, uint256 _value) public returns (bool success) {
        allowed[msg.sender][_spender] = _value;
        emit Approval(msg.sender, _spender, _value);
        return true;

    function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
        return allowed[_owner][_spender];

    function() public payable{     *//Fallback problem concerning this function*

        uint toMint = msg.value/price;
        totalSupply += toMint;
        emit Transfer(0, msg.sender, toMint);

  • 1
    Just change public by external
    – Jaime
    Commented Mar 8, 2019 at 14:06

1 Answer 1


The fallback function signature must look something like this:

function() external payable { ... }


function() external { ... }

A fallback function is used when no function is provided or if the function requested does not exist. There is no good reason why a contract would need this capability when making internal calls, so for clarity Solidity requires you only use it for external calls.

For more, see https://solidity.readthedocs.io/en/v0.5.5/contracts.html#fallback-function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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