mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6192 from ethereum/prepare060
Some missed entries and set version to 0.6.0.
This commit is contained in:
commit
17adccaa1c
@ -10,7 +10,7 @@ include(EthPolicy)
|
||||
eth_policy()
|
||||
|
||||
# project name and version should be set after cmake_policy CMP0048
|
||||
set(PROJECT_VERSION "0.5.5")
|
||||
set(PROJECT_VERSION "0.6.0")
|
||||
project(solidity VERSION ${PROJECT_VERSION} LANGUAGES CXX)
|
||||
|
||||
option(LLL "Build LLL" OFF)
|
||||
|
17
Changelog.md
17
Changelog.md
@ -1,3 +1,18 @@
|
||||
### 0.6.0 (unreleased)
|
||||
|
||||
Language Features:
|
||||
|
||||
|
||||
Compiler Features:
|
||||
|
||||
|
||||
Bugfixes:
|
||||
|
||||
|
||||
Build System:
|
||||
|
||||
|
||||
|
||||
### 0.5.5 (2019-03-05)
|
||||
|
||||
Language Features:
|
||||
@ -7,10 +22,12 @@ Language Features:
|
||||
|
||||
Compiler Features:
|
||||
* Support ``petersburg`` as ``evmVersion`` and set as default.
|
||||
* Commandline Interface: Option to activate the experimental yul optimizer using ``-optimize-yul``.
|
||||
* Inline Assembly: Consider ``extcodehash`` as part of Constantinople.
|
||||
* Inline Assembly: Instructions unavailable to the currently configured EVM are errors now.
|
||||
* SMTChecker: Do not report underflow/overflow if they always revert. This removes false positives when using ``SafeMath``.
|
||||
* Standard JSON Interface: Allow retrieving metadata without triggering bytecode generation.
|
||||
* Standard JSON Interface: Provide fine-grained control over the optimizer via the settings.
|
||||
* Static Analyzer: Warn about expressions with custom types when they have no effect.
|
||||
* Optimizer: Add new rules with constants including ``LT``, ``GT``, ``AND`` and ``BYTE``.
|
||||
* Optimizer: Add rule for shifts with constants for Constantinople.
|
||||
|
@ -308,7 +308,7 @@ This will no longer compile with Solidity v0.5.0. However, you can define a comp
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
interface OldContract {
|
||||
function someOldFunction(uint8 a) external;
|
||||
function anotherOldFunction() external returns (bool);
|
||||
@ -325,7 +325,7 @@ Given the interface defined above, you can now easily use the already deployed p
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
|
||||
interface OldContract {
|
||||
function someOldFunction(uint8 a) external;
|
||||
@ -345,7 +345,7 @@ commandline compiler for linking):
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
|
||||
library OldLibrary {
|
||||
function someFunction(uint8 a) public returns(bool);
|
||||
@ -430,7 +430,7 @@ New version:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
|
||||
contract OtherContract {
|
||||
uint x;
|
||||
|
@ -212,7 +212,7 @@ Given the contract:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
contract Foo {
|
||||
function bar(bytes3[2] memory) public pure {}
|
||||
@ -483,7 +483,7 @@ For example,
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
|
||||
contract Test {
|
||||
constructor() public { b = hex"12345678901234567890123456789012"; }
|
||||
@ -530,7 +530,7 @@ As an example, the code
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.19 <0.6.0;
|
||||
pragma solidity >=0.4.19 <0.7.0;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract Test {
|
||||
|
@ -76,7 +76,7 @@ idea is that assembly libraries will be used to enhance the Solidity language.
|
||||
|
||||
.. code::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
library GetCode {
|
||||
function at(address _addr) public view returns (bytes memory o_code) {
|
||||
@ -101,7 +101,7 @@ efficient code, for example:
|
||||
|
||||
.. code::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
library VectorSum {
|
||||
// This function is less efficient because the optimizer currently fails to
|
||||
@ -394,7 +394,7 @@ Local Solidity variables are available for assignments, for example:
|
||||
|
||||
.. code::
|
||||
|
||||
pragma solidity >=0.4.11 <0.6.0;
|
||||
pragma solidity >=0.4.11 <0.7.0;
|
||||
|
||||
contract C {
|
||||
uint b;
|
||||
@ -433,7 +433,7 @@ be just ``0``, but it can also be a complex functional-style expression.
|
||||
|
||||
.. code::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
contract C {
|
||||
function f(uint x) public view returns (uint b) {
|
||||
@ -690,7 +690,7 @@ Example:
|
||||
We will follow an example compilation from Solidity to assembly.
|
||||
We consider the runtime bytecode of the following Solidity program::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
contract C {
|
||||
function f(uint x) public pure returns (uint y) {
|
||||
|
@ -28,7 +28,7 @@ become the new richest.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
|
||||
contract WithdrawalContract {
|
||||
address public richest;
|
||||
@ -65,7 +65,7 @@ This is as opposed to the more intuitive sending pattern:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
|
||||
contract SendContract {
|
||||
address payable public richest;
|
||||
@ -130,7 +130,7 @@ restrictions highly readable.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
pragma solidity >=0.4.22 <0.7.0;
|
||||
|
||||
contract AccessRestriction {
|
||||
// These will be assigned at the construction
|
||||
@ -282,7 +282,7 @@ function finishes.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
pragma solidity >=0.4.22 <0.7.0;
|
||||
|
||||
contract StateMachine {
|
||||
enum Stages {
|
||||
|
@ -8,7 +8,7 @@ Abstract Contracts
|
||||
|
||||
Contracts are marked as abstract when at least one of their functions lacks an implementation as in the following example (note that the function declaration header is terminated by ``;``)::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract Feline {
|
||||
function utterance() public returns (bytes32);
|
||||
@ -16,7 +16,7 @@ Contracts are marked as abstract when at least one of their functions lacks an i
|
||||
|
||||
Such contracts cannot be compiled (even if they contain implemented functions alongside non-implemented functions), but they can be used as base contracts::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract Feline {
|
||||
function utterance() public returns (bytes32);
|
||||
|
@ -26,7 +26,7 @@ value types and strings.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract C {
|
||||
uint constant x = 32**22 + 8;
|
||||
|
@ -33,7 +33,7 @@ This means that cyclic creation dependencies are impossible.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
pragma solidity >=0.4.22 <0.7.0;
|
||||
|
||||
contract OwnedToken {
|
||||
// `TokenCreator` is a contract type that is defined below.
|
||||
|
@ -63,7 +63,7 @@ not possible to filter for specific anonymous events by name.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.21 <0.6.0;
|
||||
pragma solidity >=0.4.21 <0.7.0;
|
||||
|
||||
contract ClientReceipt {
|
||||
event Deposit(
|
||||
@ -136,7 +136,7 @@ as topics. The event call above can be performed in the same way as
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.10 <0.6.0;
|
||||
pragma solidity >=0.4.10 <0.7.0;
|
||||
|
||||
contract C {
|
||||
function f() public payable {
|
||||
|
@ -12,7 +12,7 @@ inheritable properties of contracts and may be overridden by derived contracts.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
|
||||
contract owned {
|
||||
constructor() public { owner = msg.sender; }
|
||||
|
@ -23,7 +23,7 @@ unused parameters can be omitted.
|
||||
For example, if you want your contract to accept one kind of external call
|
||||
with two integers, you would use something like::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
contract Simple {
|
||||
uint sum;
|
||||
@ -55,7 +55,7 @@ Function return variables are declared with the same syntax after the
|
||||
For example, suppose you want to return two results: the sum and the product of
|
||||
two integers passed as function parameters, then you use something like::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
contract Simple {
|
||||
function arithmetic(uint _a, uint _b)
|
||||
@ -78,7 +78,7 @@ or you can provide return values
|
||||
(either a single or :ref:`multiple ones<multi-return>`) directly with the ``return``
|
||||
statement::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
contract Simple {
|
||||
function arithmetic(uint _a, uint _b)
|
||||
@ -140,7 +140,7 @@ The following statements are considered modifying the state:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
|
||||
contract C {
|
||||
function f(uint a, uint b) public view returns (uint) {
|
||||
@ -185,7 +185,7 @@ In addition to the list of state modifying statements explained above, the follo
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
|
||||
contract C {
|
||||
function f(uint a, uint b) public pure returns (uint) {
|
||||
@ -279,7 +279,7 @@ Like any function, the fallback function can execute complex operations as long
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
|
||||
contract Test {
|
||||
// This function is called for all messages sent to
|
||||
@ -330,7 +330,7 @@ The following example shows overloading of the function
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
contract A {
|
||||
function f(uint _in) public pure returns (uint out) {
|
||||
@ -348,7 +348,7 @@ externally visible functions differ by their Solidity types but not by their ext
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
// This will not compile
|
||||
contract A {
|
||||
@ -381,7 +381,7 @@ candidate, resolution fails.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
contract A {
|
||||
function f(uint8 _in) public pure returns (uint8 out) {
|
||||
|
@ -23,7 +23,7 @@ Details are given in the following example.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
|
||||
contract owned {
|
||||
constructor() public { owner = msg.sender; }
|
||||
@ -95,7 +95,7 @@ Note that above, we call ``mortal.kill()`` to "forward" the
|
||||
destruction request. The way this is done is problematic, as
|
||||
seen in the following example::
|
||||
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
pragma solidity >=0.4.22 <0.7.0;
|
||||
|
||||
contract owned {
|
||||
constructor() public { owner = msg.sender; }
|
||||
@ -124,7 +124,7 @@ derived override, but this function will bypass
|
||||
``Base1.kill``, basically because it does not even know about
|
||||
``Base1``. The way around this is to use ``super``::
|
||||
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
pragma solidity >=0.4.22 <0.7.0;
|
||||
|
||||
contract owned {
|
||||
constructor() public { owner = msg.sender; }
|
||||
@ -188,7 +188,7 @@ equivalent to ``constructor() public {}``. For example:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
|
||||
contract A {
|
||||
uint public a;
|
||||
@ -218,7 +218,7 @@ The constructors of all the base contracts will be called following the
|
||||
linearization rules explained below. If the base constructors have arguments,
|
||||
derived contracts need to specify all of them. This can be done in two ways::
|
||||
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
pragma solidity >=0.4.22 <0.7.0;
|
||||
|
||||
contract Base {
|
||||
uint x;
|
||||
@ -277,7 +277,7 @@ error "Linearization of inheritance graph impossible".
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract X {}
|
||||
contract A is X {}
|
||||
|
@ -22,7 +22,7 @@ Interfaces are denoted by their own keyword:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
|
||||
interface Token {
|
||||
enum TokenType { Fungible, NonFungible }
|
||||
|
@ -47,7 +47,7 @@ more advanced example to implement a set).
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
pragma solidity >=0.4.22 <0.7.0;
|
||||
|
||||
library Set {
|
||||
// We define a new struct datatype that will be used to
|
||||
@ -121,7 +121,7 @@ custom types without the overhead of external function calls:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
library BigInt {
|
||||
struct bigint {
|
||||
|
@ -31,7 +31,7 @@ available without having to add further code.
|
||||
Let us rewrite the set example from the
|
||||
:ref:`libraries` in this way::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
// This is the same code as before, just without comments
|
||||
library Set {
|
||||
@ -81,7 +81,7 @@ Let us rewrite the set example from the
|
||||
|
||||
It is also possible to extend elementary types in that way::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
library Search {
|
||||
function indexOf(uint[] storage self, uint value)
|
||||
|
@ -53,7 +53,7 @@ return parameter list for functions.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
contract C {
|
||||
function f(uint a) private pure returns (uint b) { return a + 1; }
|
||||
@ -67,7 +67,7 @@ In the following example, ``D``, can call ``c.getData()`` to retrieve the value
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract C {
|
||||
uint private data;
|
||||
@ -111,7 +111,7 @@ when they are declared.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract C {
|
||||
uint public data = 42;
|
||||
@ -131,7 +131,7 @@ it evaluates to a state variable. If it is accessed externally
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract C {
|
||||
uint public data;
|
||||
@ -150,7 +150,7 @@ to write a function, for example:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract arrayExample {
|
||||
// public state variable
|
||||
@ -176,7 +176,7 @@ The next example is more complex:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract Complex {
|
||||
struct Data {
|
||||
|
@ -404,4 +404,4 @@ Common Terms
|
||||
Code Examples
|
||||
-------------
|
||||
|
||||
* Ensure that all code examples begin with a ``pragma`` version that spans the largest where the contract code is valid. For example ``pragma solidity >=0.4.0 <0.6.0;``.
|
||||
* Ensure that all code examples begin with a ``pragma`` version that spans the largest where the contract code is valid. For example ``pragma solidity >=0.4.0 <0.7.0;``.
|
@ -37,7 +37,7 @@ Internal Function Calls
|
||||
Functions of the current contract can be called directly ("internally"), also recursively, as seen in
|
||||
this nonsensical example::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
contract C {
|
||||
function g(uint a) public pure returns (uint ret) { return a + f(); }
|
||||
@ -75,7 +75,7 @@ When calling functions of other contracts, you can specify the amount of Wei or
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract InfoFeed {
|
||||
function info() public payable returns (uint ret) { return 42; }
|
||||
@ -122,7 +122,7 @@ parameters from the function declaration, but can be in arbitrary order.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract C {
|
||||
mapping(uint => uint) data;
|
||||
@ -145,7 +145,7 @@ Those parameters will still be present on the stack, but they are inaccessible.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
contract C {
|
||||
// omitted name for parameter
|
||||
@ -168,7 +168,7 @@ is compiled so recursive creation-dependencies are not possible.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
|
||||
contract D {
|
||||
uint public x;
|
||||
@ -225,7 +225,7 @@ groupings of expressions.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >0.4.23 <0.6.0;
|
||||
pragma solidity >0.4.23 <0.7.0;
|
||||
|
||||
contract C {
|
||||
uint[] data;
|
||||
@ -270,7 +270,7 @@ because only a reference and not a copy is passed.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
contract C {
|
||||
uint[20] x;
|
||||
@ -316,7 +316,7 @@ the two variables have the same name but disjoint scopes.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
contract C {
|
||||
function minimalScoping() pure public {
|
||||
{
|
||||
@ -337,7 +337,7 @@ In any case, you will get a warning about the outer variable being shadowed.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
// This will report a warning
|
||||
contract C {
|
||||
function f() pure public returns (uint) {
|
||||
@ -357,7 +357,7 @@ In any case, you will get a warning about the outer variable being shadowed.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
// This will not compile
|
||||
contract C {
|
||||
function f() pure public returns (uint) {
|
||||
@ -404,7 +404,7 @@ a message string for ``require``, but not for ``assert``.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
|
||||
contract Sharer {
|
||||
function sendHalf(address payable addr) public payable returns (uint balance) {
|
||||
@ -450,7 +450,7 @@ The following example shows how an error string can be used together with revert
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
|
||||
contract VendingMachine {
|
||||
function buy(uint amount) public payable {
|
||||
|
@ -30,7 +30,7 @@ activate themselves.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
pragma solidity >=0.4.22 <0.7.0;
|
||||
|
||||
contract SimpleAuction {
|
||||
// Parameters of the auction. Times are either
|
||||
@ -194,7 +194,7 @@ high or low invalid bids.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >0.4.23 <0.6.0;
|
||||
pragma solidity >0.4.23 <0.7.0;
|
||||
|
||||
contract BlindAuction {
|
||||
struct Bid {
|
||||
|
@ -112,7 +112,7 @@ The full contract
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.24 <0.6.0;
|
||||
pragma solidity >=0.4.24 <0.7.0;
|
||||
|
||||
contract ReceiverPays {
|
||||
address owner = msg.sender;
|
||||
@ -286,7 +286,7 @@ The full contract
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.24 <0.6.0;
|
||||
pragma solidity >=0.4.24 <0.7.0;
|
||||
|
||||
contract SimplePaymentChannel {
|
||||
address payable public sender; // The account sending payments.
|
||||
|
@ -11,7 +11,7 @@ addresses match what you expect.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
pragma solidity >=0.4.22 <0.7.0;
|
||||
|
||||
library Balances {
|
||||
function move(mapping(address => uint256) storage balances, address from, address to, uint amount) internal {
|
||||
|
@ -6,7 +6,7 @@ Safe Remote Purchase
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
pragma solidity >=0.4.22 <0.7.0;
|
||||
|
||||
contract Purchase {
|
||||
uint public value;
|
||||
|
@ -32,7 +32,7 @@ of votes.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
pragma solidity >=0.4.22 <0.7.0;
|
||||
|
||||
/// @title Voting with delegation.
|
||||
contract Ballot {
|
||||
|
@ -17,7 +17,7 @@ Storage
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract SimpleStorage {
|
||||
uint storedData;
|
||||
@ -81,7 +81,7 @@ registering with username and password — all you need is an Ethereum keypair.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
|
||||
contract Coin {
|
||||
// The keyword "public" makes those variables
|
||||
|
@ -280,7 +280,7 @@ for the two function parameters and two return variables.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
/** @title Shape calculator. */
|
||||
contract ShapeCalculator {
|
||||
|
@ -62,7 +62,7 @@ non-elementary type, the positions are found by adding an offset of ``keccak256(
|
||||
|
||||
So for the following contract snippet::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract C {
|
||||
struct s { uint a; uint b; }
|
||||
|
@ -55,7 +55,7 @@ complete contract):
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
// THIS CONTRACT CONTAINS A BUG - DO NOT USE
|
||||
contract Fund {
|
||||
@ -78,7 +78,7 @@ as it uses ``call`` which forwards all remaining gas by default:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
// THIS CONTRACT CONTAINS A BUG - DO NOT USE
|
||||
contract Fund {
|
||||
@ -97,7 +97,7 @@ outlined further below:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.11 <0.6.0;
|
||||
pragma solidity >=0.4.11 <0.7.0;
|
||||
|
||||
contract Fund {
|
||||
/// Mapping of ether shares of the contract.
|
||||
@ -183,7 +183,7 @@ Never use tx.origin for authorization. Let's say you have a wallet contract like
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
|
||||
// THIS CONTRACT CONTAINS A BUG - DO NOT USE
|
||||
contract TxUserWallet {
|
||||
@ -203,7 +203,7 @@ Now someone tricks you into sending ether to the address of this attack wallet:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.5.0;
|
||||
pragma solidity >=0.5.0 <0.7.0;
|
||||
|
||||
interface TxUserWallet {
|
||||
function transferTo(address payable dest, uint amount) external;
|
||||
|
@ -26,7 +26,7 @@ storage.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract SimpleStorage {
|
||||
uint storedData; // State variable
|
||||
@ -46,7 +46,7 @@ Functions are the executable units of code within a contract.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract SimpleAuction {
|
||||
function bid() public payable { // Function
|
||||
@ -69,7 +69,7 @@ Function modifiers can be used to amend the semantics of functions in a declarat
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
pragma solidity >=0.4.22 <0.7.0;
|
||||
|
||||
contract Purchase {
|
||||
address public seller;
|
||||
@ -96,7 +96,7 @@ Events are convenience interfaces with the EVM logging facilities.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.21 <0.6.0;
|
||||
pragma solidity >=0.4.21 <0.7.0;
|
||||
|
||||
contract SimpleAuction {
|
||||
event HighestBidIncreased(address bidder, uint amount); // Event
|
||||
@ -120,7 +120,7 @@ Structs are custom defined types that can group several variables (see
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract Ballot {
|
||||
struct Voter { // Struct
|
||||
@ -141,7 +141,7 @@ Enums can be used to create custom types with a finite set of 'constant values'
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract Purchase {
|
||||
enum State { Created, Locked, Inactive } // Enum
|
||||
|
@ -52,7 +52,7 @@ Surround top level declarations in solidity source with two blank lines.
|
||||
|
||||
Yes::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract A {
|
||||
// ...
|
||||
@ -70,7 +70,7 @@ Yes::
|
||||
|
||||
No::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract A {
|
||||
// ...
|
||||
@ -89,7 +89,7 @@ Blank lines may be omitted between groups of related one-liners (such as stub fu
|
||||
|
||||
Yes::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract A {
|
||||
function spam() public pure;
|
||||
@ -109,7 +109,7 @@ Yes::
|
||||
|
||||
No::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract A {
|
||||
function spam() public pure {
|
||||
@ -237,7 +237,7 @@ Import statements should always be placed at the top of the file.
|
||||
|
||||
Yes::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
import "./Owned.sol";
|
||||
|
||||
@ -251,7 +251,7 @@ Yes::
|
||||
|
||||
No::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract A {
|
||||
// ...
|
||||
@ -283,7 +283,7 @@ Within a grouping, place the ``view`` and ``pure`` functions last.
|
||||
|
||||
Yes::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract A {
|
||||
constructor() public {
|
||||
@ -315,7 +315,7 @@ Yes::
|
||||
|
||||
No::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract A {
|
||||
|
||||
@ -411,7 +411,7 @@ should:
|
||||
|
||||
Yes::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract Coin {
|
||||
struct Bank {
|
||||
@ -422,7 +422,7 @@ Yes::
|
||||
|
||||
No::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract Coin
|
||||
{
|
||||
@ -723,7 +723,7 @@ manner as modifiers if the function declaration is long or hard to read.
|
||||
|
||||
Yes::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
// Base contracts just to make this compile
|
||||
contract B {
|
||||
@ -755,7 +755,7 @@ Yes::
|
||||
|
||||
No::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
// Base contracts just to make this compile
|
||||
contract B {
|
||||
@ -971,7 +971,7 @@ As shown in the example below, if the contract name is `Congress` and the librar
|
||||
|
||||
Yes::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
// Owned.sol
|
||||
contract Owned {
|
||||
@ -1000,7 +1000,7 @@ Yes::
|
||||
|
||||
No::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
// owned.sol
|
||||
contract owned {
|
||||
@ -1104,7 +1104,7 @@ multiline comment starting with `/**` and ending with `*/`.
|
||||
For example, the contract from `a simple smart contract <simple-smart-contract>`_ with the comments
|
||||
added looks like the one below::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
/// @author The Solidity Team
|
||||
/// @title A simple storage example
|
||||
|
@ -34,7 +34,7 @@ each ``_KeyType``, recursively. For example with a mapping:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract MappingExample {
|
||||
mapping(address => uint) public balances;
|
||||
|
@ -27,7 +27,7 @@ value it referred to previously.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract DeleteExample {
|
||||
uint data;
|
||||
|
@ -49,7 +49,7 @@ Data locations are not only relevant for persistency of data, but also for the s
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
contract C {
|
||||
uint[] x; // the data location of x is storage
|
||||
@ -146,7 +146,7 @@ or create a new memory array and copy every element.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
contract C {
|
||||
function f(uint len) public pure {
|
||||
@ -175,7 +175,7 @@ In the example below, the type of ``[1, 2, 3]`` is
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
contract C {
|
||||
function f() public pure {
|
||||
@ -190,7 +190,7 @@ Fixed size memory arrays cannot be assigned to dynamically-sized memory arrays,
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.0 <0.6.0;
|
||||
pragma solidity >=0.4.0 <0.7.0;
|
||||
|
||||
// This will not compile.
|
||||
contract C {
|
||||
@ -248,7 +248,7 @@ Array Members
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
contract ArrayContract {
|
||||
uint[2**20] m_aLotOfIntegers;
|
||||
@ -347,7 +347,7 @@ shown in the following example:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.11 <0.6.0;
|
||||
pragma solidity >=0.4.11 <0.7.0;
|
||||
|
||||
contract CrowdFunding {
|
||||
// Defines a new type with two fields.
|
||||
|
@ -517,7 +517,7 @@ subsequent unsigned integer values starting from ``0``.
|
||||
|
||||
::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
contract test {
|
||||
enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill }
|
||||
@ -621,7 +621,7 @@ Public (or external) functions have the following members:
|
||||
|
||||
Example that shows how to use the members::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
contract Example {
|
||||
function f() public payable returns (bytes4) {
|
||||
@ -634,7 +634,7 @@ Example that shows how to use the members::
|
||||
|
||||
Example that shows how to use internal function types::
|
||||
|
||||
pragma solidity >=0.4.16 <0.6.0;
|
||||
pragma solidity >=0.4.16 <0.7.0;
|
||||
|
||||
library ArrayUtils {
|
||||
// internal functions can be used in internal library functions because
|
||||
@ -685,7 +685,7 @@ Example that shows how to use internal function types::
|
||||
|
||||
Another example that uses external function types::
|
||||
|
||||
pragma solidity >=0.4.22 <0.6.0;
|
||||
pragma solidity >=0.4.22 <0.7.0;
|
||||
|
||||
contract Oracle {
|
||||
struct Request {
|
||||
|
Loading…
Reference in New Issue
Block a user