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
• 27,620 points
48 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,040 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
• 16,450 points
33 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
• 16,450 points
114 views
0 votes
1 answer

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

Here's a simple example for web3js 1.0.0.beta*: function handler ...READ MORE

answered Jun 8, 2018 in Blockchain by ariaholic
• 7,320 points
249 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
• 66,910 points
965 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
81 views
0 votes
1 answer
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
• 66,910 points
41 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,040 points
33 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.