Solidity 0.6.11 更新

栏目: IT技术 · 发布时间: 5年前

内容简介:Solidity 0.6.11 更新本文参与登链社区写作激励计划 ,好文好收益,欢迎正在阅读的你也加入。

Solidity 0.6.11 更新

Solidity 0.6.11 更新:

Solidity v0.6.11 adds inheritance to NatSpec comments, improves debugging data output and fixes some minor issues with opening up calldata for non-external functions.

Notable New Features

NatSpec Inheritance and on Events

NatSpec comments are a way to describe the behaviour of a function to end-users. It also allows to provide more detailed information to developers.

One regular use-case is that you document the behaviour of an interface and then implement the interface in a derived contract. Previously, you had to repeat the documentation in the derived contract. This is now obsolete: The compiler will automatically inherit the documentation of the base function if the derived function does not provide any NatSpec tag.

If you provide any of the tags ( @param , @dev , …), 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!

Furhermore, NatSpec is now supported on events.

// 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);
  }
}

The derived contract MyGathering in the example code above will produce the following 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
}

Unit Denomination gwei

You can now use gwei as a unit denomination alongside wei , szabo , finney and ether :

reqire(msg.value >= 10 gwei);

Solidity 0.6.11 更新:

Solidity v0.6.11 adds inheritance to NatSpec comments, improves debugging data output and fixes some minor issues with opening up calldata for non-external functions.

Notable New Features

NatSpec Inheritance and on Events

NatSpec comments are a way to describe the behaviour of a function to end-users. It also allows to provide more detailed information to developers.

One regular use-case is that you document the behaviour of an interface and then implement the interface in a derived contract. Previously, you had to repeat the documentation in the derived contract. This is now obsolete: The compiler will automatically inherit the documentation of the base function if the derived function does not provide any NatSpec tag.

If you provide any of the tags ( @param , @dev , …), 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!

Furhermore, NatSpec is now supported on events.

// 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);
  }
}

The derived contract MyGathering in the example code above will produce the following 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
}

Unit Denomination gwei

You can now use gwei as a unit denomination alongside wei , szabo , finney and ether :

reqire(msg.value >= 10 gwei);

本文参与登链社区写作激励计划 ,好文好收益,欢迎正在阅读的你也加入。

  • 发表于 24分钟前
  • 阅读 ( 12 )
  • 学分 ( 0 )
  • 分类:Solidity

以上所述就是小编给大家介绍的《Solidity 0.6.11 更新》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

ACM国际大学生程序设计竞赛亚洲区预选赛真题题解

ACM国际大学生程序设计竞赛亚洲区预选赛真题题解

郭炜 / 电子工业 / 2011-7 / 49.00元

ACM国际大学生程序设计竞赛(ACM International Collegiate Programming Contest,简称ACM/ICPC)是世界上历史最悠久,规模最大、最具声望的程序设计竞赛,一直受到众多国际知名大学的重视,全球著名IT公司更是争相招募竞赛的优胜者。 该项赛事分为各大洲预选赛和全球总决赛两个阶段。北京大学多次在亚洲区预选赛中负责命题工作,是中国在ACM/ICPC命......一起来看看 《ACM国际大学生程序设计竞赛亚洲区预选赛真题题解》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具