I'm trying to create an ERC20 token and if someone sends ether to this contract, contract will send equivalent tokens to the calling address.


pragma solidity ^0.6.6;

import "./new1ERC20.sol";

  contract ConfigureERC20 is new1ERC20 {

     uint256 tokenPrice = 500000000000000 wei;
     uint256 public tokensToGet = 0;

     fallback() external payable {
        require(msg.value > 0);
     //   require(tokensRemaining > 0);
        tokensToGet = msg.value / tokenPrice;

        //_balances[] = balances[fundsWallet] - amount;
        //_balances[msg.sender] = _balances[msg.sender].add(balance);
        emit Transfer(address(this), msg.sender, tokensToGet);



  • 1. In that screenshot, the error-message hides some of your code (and worse - what appears to be the most relevant part of it). 2. Please post everything in plain copy/pastable text (no links or images). Also, please make sure that it is properly formatted (3 ticks at the beginning and 3 ticks at the end). – goodvibration May 7 at 2:30
  • @goodvibration thanks, i'm new to this forum so please bear with me, i have edit it please check it now – sultan May 7 at 5:27

As @goodvibration mentioned you have failed to post the essential parts of the code.

Anyway, based on the error message you are most likely using the pre-0.6 style of defining a single fallback function like this:

function() payable external { } (https://solidity.readthedocs.io/en/v0.5.3/contracts.html#fallback-function)

In Solidity version 0.6 the way of defining fallback functions was changed. There are now two separate functions: receive and fallback and their signature have changed - they are incompatible with pre-0.6 versions. So the function signatures are:

fallback() external { } and

receive() external payable { }


If you use Solidity version 0.6 or greater you can't use the old-style single fallback function anymore. So upgrade your code to conform to the new style and you should be ok.

| improve this answer | |

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.