0

i am trying to deploy a test erc20 token with truffle on ganache-cli My migration file name 2_deploy_contracts.js here is the code for it:

var erc20 = artifacts.require('./ERC20.sol');

module.exports = function(deployer)
{
    deployer.deploy(erc20);
}

When i deploy my ERC20 contract i get this error:

2_deploys_contract.js
=====================
Error:  *** Deployment Failed ***

"ERC20" is an abstract contract or an interface and cannot be deployed.
   * Import abstractions into the '.sol' file that uses them instead of deploying them separately.
   * Contracts that inherit an abstraction must implement all its method signatures exactly.
   * A contract that only implements part of an inherited abstraction is also considered abstract.

    at Deployer._preFlightCheck (/usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-deployer/src/deployment.js:178:1)
    at <anonymous>
Truffle v5.0.0 (core: 5.0.0)
Node v8.11.2

Here is my ERC20.sol contract:

pragma solidity >= 0.4.0 < 0.6.0;

contract ERC20
{

    /*
    EVENT
    */
    event Transfer(address from, address to, uint256 value);
    event Approval(address tokenOwner, address spender, uint256 tokens);


    struct Allowance
    {
        uint256 amount;
        bool used;
    }
    mapping (address => uint256) balances;
    mapping (address => mapping(address => Allowance)) allowed;
    uint256 private TotalSupply;
    address internal owner;


    constructor() internal 
    {
        owner == msg.sender;
        TotalSupply = 200;
        balances[owner] = TotalSupply;
        emit Transfer(address(0), owner, TotalSupply);
    }


    function totalSupply() public view returns(uint)
    {
        return TotalSupply;
    }

    function balanceOf(address tokenOwner) public view returns(uint256)
    {
        return balances[tokenOwner];
    }

    function allowance(address tokenOwner, address spender) public view returns (uint256 remaining)
    {
        return allowed[tokenOwner][spender].amount;
    }

    function approve(address spender, uint256 value) public returns(bool success)
    {
        require(balances[msg.sender] >= value, "Insufficient balance");
        require(value == 0 ||
                ( allowed[msg.sender][spender].amount == 0 &&
                !allowed[msg.sender][spender].used ), "Please set your value to 0 before you allow");
        allowed[msg.sender][spender].used = false;
        allowed[msg.sender][spender].amount = value;
        emit Approval(msg.sender, spender, value);
        return true;
    }

    function transfer(address to, uint256 value) public returns(bool success)
    {
        require(to != address(0));
        require(balances[msg.sender] >= value, "Insufficient balance");

        balances[msg.sender] -= value;
        balances[to] += value;
        emit Transfer(msg.sender, to, value);
        return true;
    }

    function tranferFrom(address from, address to, uint256 value) public returns(bool success)
    {
        require(to != address(0));
        require(value <= allowed[msg.sender][from].amount);

        allowed[from][msg.sender].amount += value;
        balances[from] -= value;
        balances[to] += value;

        if(value > 0){
            allowed[from][msg.sender].used = true;
        }

        emit Transfer(from, to, value);
        return true;
    }
}

my contract folder only have Migrations.sol for migrate and the above contract ERC20.sol So my question is how to fix that error

1

You get this error because the constructor is declared internal.

Whoever wrote this contract meant for it to be extended (inherited) and only then deployed.

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.