首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >已声明的标识符

已声明的标识符
EN

Ethereum用户
提问于 2021-05-03 03:02:48
回答 1查看 444关注 0票数 0
代码语言:javascript
运行
复制
event transfer(address indexed from, address indexed to, uint value);
    event Approval (address indexed owner, address indexed spender, uint value);
    
    constructor(){
        balances[msg.sender] = totalSupply; 
    }
    
    function balanceOf(address owner) public view   returns(uint) {
        return balances[owner];  
    }
    
    function transfer(address to, uint value) public  returns(bool) {
        require(balanceOf(msg.sender) >= value, 'balance too low');
        balances[to] +=value;
        balances[msg.sender] -=value;
        emit transfer(msg.sender, to, value);
        return true;
    }

当我试图在remix中编译一个契约时,我得到了这个错误:

代码语言:javascript
运行
复制
DeclarationError: Identifier already declared. --> Token.sol:23:5: | 23 | 
function transfer(address to, uint value) public returns(bool) { | ^ (Relevant source part starts here and spans across multiple lines). Note: The previous declaration is here: --> Token.sol:12:5: | 12 | event transfer(address indexed from, address indexed to, uint value); | 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
EN

回答 1

Ethereum用户

发布于 2021-05-03 06:43:30

您的事件和功能转移具有相同的名称。更改您的函数名。

票数 0
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/98182

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档