前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Solidity 0.6.11 更新

Solidity 0.6.11 更新

作者头像
Tiny熊
发布2020-07-28 16:26:47
3970
发布2020-07-28 16:26:47
举报

Solidity v0.6.11[1] 为 NatSpec 注释添加了继承性,改进了调试数据输出,并修复了为非外部函数打开calldata的一些小问题。

值得关注的改进

文档注释防范(NatSpec)支持了继承及事件

NatSpec 注释是一种向最终用户描述函数行为的方式。以便为开发者提供更详细的信息。

一个常见的用例是用来记录接口的行为,然后在派生合约(子合约)中实现该接口。以前,必须派生合约中复制文档。现在不需要了,如果派生函数不提供任何 NatSpec 标签,则编译器将自动继承父合约函数的文档。

如果在派生合约函数中使用了任何标签(@param, @dev, …),则不会继承,在这种情况下,下一个发行版将提供一项功能,以明确地从某个特定父合约继承,因此请继续关注!

If you provide any of the tags (), then nothing will be inherited. The next release will provide a feature to explicitly inherit from a certain base also in that case, so stay tuned!

此外,事件现在支持 NatSpec。

// SPDX-License-Identifier: MIT
pragma solidity ^0.6.11;
interface Gathering {
  /// The address `participant` just registered for the gathering.
  event Registered(address participant);

  /// Registers `msg.sender` to take part in the gathering.
  function register() external;
}

contract MyGathering is Gathering {
  mapping(address => bool) public participants;

  function register() public override {
    participants[msg.sender] = true;
    emit Registered(msg.sender);
  }
}

在以上示例的派生合约MyGathering 会生成一下的用户文档(userdoc):

{
    "events": {
        "Registered(address)": {
            "notice": "The address `participant` just registered for the gathering."
        }
    },
    "kind": "user",
    "methods": {
        "register()": {
            "notice": "Registers `msg.sender` to take part in the gathering."
        }
    },
    "version": 1
}

新的单位面值 gwei

现在可以使用 gwei 作为单位了,就像使用 wei, szabo, finneyether 一样:

reqire(msg.value >= 10 gwei);

参考资料

[1]

Solidity v0.6.11: https://github.com/ethereum/solidity/releases/tag/v0.6.11


本文作者:Tiny熊

作者主页:

https://learnblockchain.cn/people/15


本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-07-23,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 深入浅出区块链技术 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 值得关注的改进
    • 文档注释防范(NatSpec)支持了继承及事件
      • 新的单位面值 gwei
        • 参考资料
        领券
        问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档