首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >错误:- browser/Mycontract.sol:29:13:错误:未声明的标识符。断言(值% 10 == 0);^-^

错误:- browser/Mycontract.sol:29:13:错误:未声明的标识符。断言(值% 10 == 0);^-^
EN

Ethereum用户
提问于 2019-03-03 18:23:52
回答 1查看 158关注 0票数 2
代码语言:javascript
运行
复制
pragma solidity ^0.4.7 ;

contract MyContract
{
    string sentence = "my first sentence" ;
    address owner ;
    function MyContract()
    {
        owner = msg.sender ;

    }
    function getSentence() public constant returns(string)     {
        return sentence ;
    }
        function setSentence(string newsentence) public returns (string)
        {
            if(owner!= msg.sender)
            {
                return "don't dare to change the contract" ;
            }
            sentence = newsentence ;
            return sentence ;

        }
        uint balance=100 ;
        uint value ;
        function Transact(uint value) public returns(uint)
        {
            assert(value % 10 == 0) ;
            require(value<= balance) ;
            balance = balance - value ;
            return balance ;
        }

}   
EN

回答 1

Ethereum用户

发布于 2019-03-03 18:39:44

@Rishabh,

这是一个您正在使用的坚固版本的问题。这个(断言,要求)关键字不是0.4.7版本的一部分。

我刚刚将其升级为务实性^0.4.24;它运行得很好。

请找到可靠的文档以供参考:http://solidity.readthedocs.io/en/latest/control-structures.html#exceptions

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

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

复制
相关文章

相似问题

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