How to fix browser IERC20 sol 4 53 Warning This declaration shadows an existing declaration

0 votes

Error:

browser/IERC20.sol:4:53: Warning: This declaration shadows an existing declaration. function totalSupply() public constant returns (uint256 totalSupply);

browser/IERC20.sol:4:5: The shadowed declaration is here: function totalSupply() public constant returns (uint256 totalSupply);

IERC20.sol

pragma solidity ^0.4.17;
interface IERC20 {
function totalSupply() public constant returns (uint256 totalSupply);
function balanceOf(address _owner) public constant returns (uint256 balance);
function transfer(address _to, uint256 _value) public returns (bool success);
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
function approve(address _spender, uint256 _value) public returns (bool success);
function allowance(address _owner, address _spender) public constant returns (uint256 remaining);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}

INDToken.sol

pragma solidity ^0.4.11;

import './IERC20.sol';

contract INDToken is IERC20 {

    uint public constant _totalSupply = 1000000;

    string public constant symbol = "IND";
    string public constant name = "Indonesia Token";
    uint8 public constant decimals = 3;

    mapping(address => uint256) balances;
    mapping(address => mapping(address => uint256)) allowed;

    function INDToken() public {
        balances[msg.sender] = _totalSupply;
    }

    function totalSupply() public constant returns (uint256 totalSupply){
        return _totalSupply;
    }

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

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

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

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

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

    event Transfer(address indexed _from, address indexed _to, uint256 _value);
    event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}

Oct 1, 2018 in Blockchain by digger
• 26,740 points
1,260 views

1 answer to this question.

0 votes

I believe the issue is the reuse of the function name as the return value name. I would simply delete the name of the return value, since you're not using it anyway:

function totalSupply() public constant returns (uint256) {

As an alternative, you can name it something different:

function totalSupply() public constant returns (uint256 total) {
answered Oct 1, 2018 by slayer
• 29,350 points

Related Questions In Blockchain

0 votes
1 answer

How is a request sent from an app to a smart contract?

Yes, the contract is distributed by every node ...READ MORE

answered Jun 4, 2018 in Blockchain by Perry
• 17,100 points
558 views
0 votes
1 answer

How to get the already existing channels in Hyperledger v1.0?

You cannot see all available channels,  but you ...READ MORE

answered Jun 4, 2018 in Blockchain by Perry
• 17,100 points
2,273 views
0 votes
2 answers

How to get notified when an event triggers on ethereum smart contract?

Muchas gracias. ?Como puedo iniciar sesion? READ MORE

answered May 2, 2020 in Blockchain by aqowcmbevs
2,148 views
0 votes
1 answer

How to fix "failed to execute script docker compose" error on windows 7?

It seems like the container is not ...READ MORE

answered Jun 27, 2018 in Blockchain by Omkar
• 69,210 points
21,500 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,662 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,215 views
0 votes
1 answer

Solidity geth: Error encountered during contract execution [Bad instruction]

recipes is a dynamic storage array. You need ...READ MORE

answered Oct 15, 2018 in Blockchain by Omkar
• 69,210 points
1,237 views
0 votes
1 answer

How to track changes of an object in exonum?

You have to describe each component in ...READ MORE

answered Jul 23, 2018 in Blockchain by slayer
• 29,350 points
422 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP