Adjust docs example to work with v0.8.0

This commit is contained in:
Mathias Baumann 2020-09-08 10:48:04 +02:00
parent 559ab3f1ec
commit b72fb1333b
39 changed files with 134 additions and 134 deletions

View File

@ -311,7 +311,7 @@ This will no longer compile with Solidity v0.5.0. However, you can define a comp
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.5.0 <0.8.0;
pragma solidity >=0.5.0 <0.9.0;
interface OldContract {
function someOldFunction(uint8 a) external;
function anotherOldFunction() external returns (bool);
@ -329,7 +329,7 @@ Given the interface defined above, you can now easily use the already deployed p
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.5.0 <0.8.0;
pragma solidity >=0.5.0 <0.9.0;
interface OldContract {
function someOldFunction(uint8 a) external;

View File

@ -233,7 +233,7 @@ Given the contract:
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.8.0;
pragma solidity >=0.4.16 <0.9.0;
contract Foo {
function bar(bytes3[2] memory) public pure {}
@ -537,7 +537,7 @@ For example,
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract Test {
@ -586,7 +586,7 @@ As an example, the code
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.19 <0.8.0;
pragma solidity >=0.4.19 <0.9.0;
pragma experimental ABIEncoderV2;
contract Test {

View File

@ -42,7 +42,7 @@ without a compiler change.
.. code::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.8.0;
pragma solidity >=0.4.16 <0.9.0;
library GetCode {
function at(address _addr) public view returns (bytes memory o_code) {
@ -68,7 +68,7 @@ efficient code, for example:
.. code::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.8.0;
pragma solidity >=0.4.16 <0.9.0;
library VectorSum {
@ -140,7 +140,7 @@ Local Solidity variables are available for assignments, for example:
.. code::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract C {
uint b;

View File

@ -28,7 +28,7 @@ you receive the funds of the person who is now the richest.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract WithdrawalContract {
address public richest;
@ -62,7 +62,7 @@ This is as opposed to the more intuitive sending pattern:
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract SendContract {
address payable public richest;
@ -124,7 +124,7 @@ restrictions highly readable.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.8.0;
pragma solidity >=0.4.22 <0.9.0;
contract AccessRestriction {
// These will be assigned at the construction
@ -277,7 +277,7 @@ function finishes.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.8.0;
pragma solidity >=0.4.22 <0.9.0;
contract StateMachine {
enum Stages {

View File

@ -14,7 +14,7 @@ defined as abstract, because the function ``utterance()`` was defined, but no im
provided (no implementation body ``{ }`` was given).::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.8.0;
pragma solidity >=0.6.0 <0.9.0;
abstract contract Feline {
function utterance() public virtual returns (bytes32);
@ -24,7 +24,7 @@ Such abstract contracts can not be instantiated directly. This is also true, if
all defined functions. The usage of an abstract contract as a base class is shown in the following example::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.8.0;
pragma solidity >=0.6.0 <0.9.0;
abstract contract Feline {
function utterance() public pure virtual returns (bytes32);

View File

@ -26,7 +26,7 @@ Not all types for constants and immutables are implemented at this time. The onl
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract C {
uint constant X = 32**22 + 8;

View File

@ -35,7 +35,7 @@ This means that cyclic creation dependencies are impossible.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.8.0;
pragma solidity >=0.4.22 <0.9.0;
contract OwnedToken {

View File

@ -66,7 +66,7 @@ is that they are cheaper to deploy and call.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.21 <0.8.0;
pragma solidity >=0.4.21 <0.9.0;
contract ClientReceipt {
event Deposit(
@ -140,7 +140,7 @@ as topics. The event call above can be performed in the same way as
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.10 <0.8.0;
pragma solidity >=0.4.10 <0.9.0;
contract C {
function f() public payable {

View File

@ -18,7 +18,7 @@ if they are marked ``virtual``. For details, please see
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.7.0 <0.8.0;
pragma solidity >0.7.0 <0.9.0;
contract owned {
constructor() { owner = msg.sender; }

View File

@ -15,7 +15,7 @@ that call them, similar to internal library functions.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.7.0 <0.8.0;
pragma solidity >0.7.0 <0.9.0;
function sum(uint[] memory _arr) pure returns (uint s) {
for (uint i = 0; i < _arr.length; i++)
@ -52,7 +52,7 @@ For example, if you want your contract to accept one kind of external call
with two integers, you would use something like the following::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.8.0;
pragma solidity >=0.4.16 <0.9.0;
contract Simple {
uint sum;
@ -85,7 +85,7 @@ 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::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.8.0;
pragma solidity >=0.4.16 <0.9.0;
contract Simple {
function arithmetic(uint _a, uint _b)
@ -110,7 +110,7 @@ or you can provide return values
statement::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.8.0;
pragma solidity >=0.4.16 <0.9.0;
contract Simple {
function arithmetic(uint _a, uint _b)
@ -174,7 +174,7 @@ The following statements are considered modifying the state:
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.5.0 <0.8.0;
pragma solidity >=0.5.0 <0.9.0;
contract C {
function f(uint a, uint b) public view returns (uint) {
@ -220,7 +220,7 @@ In addition to the list of state modifying statements explained above, the follo
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.5.0 <0.8.0;
pragma solidity >=0.5.0 <0.9.0;
contract C {
function f(uint a, uint b) public pure returns (uint) {
@ -314,7 +314,7 @@ Below you can see an example of a Sink contract that uses function ``receive``.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.8.0;
pragma solidity >=0.6.0 <0.9.0;
// This contract keeps all Ether sent to it with no way
// to get it back.
@ -370,7 +370,7 @@ operations as long as there is enough gas passed on to it.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.2 <0.8.0;
pragma solidity >=0.6.2 <0.9.0;
contract Test {
// This function is called for all messages sent to
@ -443,7 +443,7 @@ The following example shows overloading of the function
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.8.0;
pragma solidity >=0.4.16 <0.9.0;
contract A {
function f(uint _in) public pure returns (uint out) {
@ -462,7 +462,7 @@ externally visible functions differ by their Solidity types but not by their ext
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.8.0;
pragma solidity >=0.4.16 <0.9.0;
// This will not compile
contract A {
@ -496,7 +496,7 @@ candidate, resolution fails.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.8.0;
pragma solidity >=0.4.16 <0.9.0;
contract A {
function f(uint8 _in) public pure returns (uint8 out) {

View File

@ -39,7 +39,7 @@ Details are given in the following example.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract Owned {
@ -127,7 +127,7 @@ destruction request. The way this is done is problematic, as
seen in the following example::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract owned {
constructor() { owner = msg.sender; }
@ -157,7 +157,7 @@ explicitly in the final override, but this function will bypass
``Base1.destroy``. The way around this is to use ``super``::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract owned {
constructor() { owner = msg.sender; }
@ -214,7 +214,7 @@ The following example demonstrates changing mutability and visibility:
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract Base
{
@ -238,7 +238,7 @@ bases, it has to explicitly override it:
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.8.0;
pragma solidity >=0.6.0 <0.9.0;
contract Base1
{
@ -265,7 +265,7 @@ that already overrides all other functions.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.8.0;
pragma solidity >=0.6.0 <0.9.0;
contract A { function f() public pure{} }
contract B is A {}
@ -306,7 +306,7 @@ of the variable:
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.8.0;
pragma solidity >=0.6.0 <0.9.0;
contract A
{
@ -338,7 +338,7 @@ and the ``override`` keyword must be used in the overriding modifier:
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.8.0;
pragma solidity >=0.6.0 <0.9.0;
contract Base
{
@ -357,7 +357,7 @@ explicitly:
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.8.0;
pragma solidity >=0.6.0 <0.9.0;
contract Base1
{
@ -405,7 +405,7 @@ equivalent to ``constructor() {}``. For example:
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
abstract contract A {
uint public a;
@ -442,7 +442,7 @@ 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::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract Base {
uint x;
@ -502,7 +502,7 @@ error "Linearization of inheritance graph impossible".
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
contract X {}
contract A is X {}
@ -523,7 +523,7 @@ One area where inheritance linearization is especially important and perhaps not
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract Base1 {
constructor() {}

View File

@ -23,7 +23,7 @@ Interfaces are denoted by their own keyword:
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.2 <0.8.0;
pragma solidity >=0.6.2 <0.9.0;
interface Token {
enum TokenType { Fungible, NonFungible }
@ -44,7 +44,7 @@ inheritance.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.2 <0.8.0;
pragma solidity >=0.6.2 <0.9.0;
interface ParentA {
function test() external returns (uint256);

View File

@ -47,7 +47,7 @@ more advanced example to implement a set).
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.8.0;
pragma solidity >=0.6.0 <0.9.0;
// We define a new struct datatype that will be used to
@ -126,7 +126,7 @@ custom types without the overhead of external function calls:
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.8.0;
pragma solidity >=0.6.0 <0.9.0;
struct bigint {
uint[] limbs;
@ -243,7 +243,7 @@ Its value can be obtained from Solidity using the ``.selector`` member as follow
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.5.14 <0.8.0;
pragma solidity >=0.5.14 <0.9.0;
library L {
function f(uint256) external {}

View File

@ -30,7 +30,7 @@ Let us rewrite the set example from the
:ref:`libraries` in this way::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.8.0;
pragma solidity >=0.6.0 <0.9.0;
// This is the same code as before, just without comments
@ -83,7 +83,7 @@ Let us rewrite the set example from the
It is also possible to extend elementary types in that way::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.8.0;
pragma solidity >=0.4.16 <0.9.0;
library Search {
function indexOf(uint[] storage self, uint value)

View File

@ -55,7 +55,7 @@ return parameter list for functions.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.8.0;
pragma solidity >=0.4.16 <0.9.0;
contract C {
function f(uint a) private pure returns (uint b) { return a + 1; }
@ -70,7 +70,7 @@ In the following example, ``D``, can call ``c.getData()`` to retrieve the value
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.8.0;
pragma solidity >=0.4.16 <0.9.0;
contract C {
uint private data;
@ -115,7 +115,7 @@ when they are declared.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.8.0;
pragma solidity >=0.4.16 <0.9.0;
contract C {
uint public data = 42;
@ -136,7 +136,7 @@ it evaluates to a state variable. If it is accessed externally
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
contract C {
uint public data;
@ -156,7 +156,7 @@ to write a function, for example:
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.8.0;
pragma solidity >=0.4.16 <0.9.0;
contract arrayExample {
// public state variable
@ -183,7 +183,7 @@ The next example is more complex:
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
contract Complex {
struct Data {

View File

@ -443,7 +443,7 @@ or ``interface`` using the ``./test/cmdlineTests.sh`` script when you create a P
ensure they work and pass tests before creating the PR.
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.8.0;``.
For example ``pragma solidity >=0.4.0 <0.9.0;``.
Running Documentation Tests
---------------------------

View File

@ -42,7 +42,7 @@ Functions of the current contract can be called directly ("internally"), also re
this nonsensical example::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.8.0;
pragma solidity >=0.4.22 <0.9.0;
contract C {
function g(uint a) public pure returns (uint ret) { return a + f(); }
@ -84,7 +84,7 @@ to the total balance of that contract:
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.2 <0.8.0;
pragma solidity >=0.6.2 <0.9.0;
contract InfoFeed {
function info() public payable returns (uint ret) { return 42; }
@ -140,7 +140,7 @@ parameters from the function declaration, but can be in arbitrary order.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
contract C {
mapping(uint => uint) data;
@ -164,7 +164,7 @@ Those parameters will still be present on the stack, but they are inaccessible.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.8.0;
pragma solidity >=0.4.22 <0.9.0;
contract C {
// omitted name for parameter
@ -188,7 +188,7 @@ is compiled so recursive creation-dependencies are not possible.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract D {
uint public x;
@ -244,7 +244,7 @@ which only need to be created if there is a dispute.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract D {
uint public x;
@ -314,7 +314,7 @@ groupings of expressions.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.5.0 <0.8.0;
pragma solidity >=0.5.0 <0.9.0;
contract C {
uint index;
@ -360,7 +360,7 @@ because only a reference and not a copy is passed.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.8.0;
pragma solidity >=0.4.22 <0.9.0;
contract C {
uint[20] x;
@ -419,7 +419,7 @@ the two variables have the same name but disjoint scopes.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.5.0 <0.8.0;
pragma solidity >=0.5.0 <0.9.0;
contract C {
function minimalScoping() pure public {
{
@ -441,7 +441,7 @@ In any case, you will get a warning about the outer variable being shadowed.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.5.0 <0.8.0;
pragma solidity >=0.5.0 <0.9.0;
// This will report a warning
contract C {
function f() pure public returns (uint) {
@ -463,7 +463,7 @@ In any case, you will get a warning about the outer variable being shadowed.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.5.0 <0.8.0;
pragma solidity >=0.5.0 <0.9.0;
// This will not compile
contract C {
function f() pure public returns (uint) {
@ -552,7 +552,7 @@ and ``assert`` for internal error checking.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.5.0 <0.8.0;
pragma solidity >=0.5.0 <0.9.0;
contract Sharer {
function sendHalf(address payable addr) public payable returns (uint balance) {
@ -597,7 +597,7 @@ The following example shows how to use an error string together with ``revert``
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.5.0 <0.8.0;
pragma solidity >=0.5.0 <0.9.0;
contract VendingMachine {
function buy(uint amount) public payable {
@ -641,7 +641,7 @@ A failure in an external call can be caught using a try/catch statement, as foll
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.8.0;
pragma solidity >=0.6.0 <0.9.0;
interface DataFeed { function getData(address token) external returns (uint value); }

View File

@ -25,7 +25,7 @@ to receive their money - contracts cannot activate themselves.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract SimpleAuction {
// Parameters of the auction. Times are either
@ -186,7 +186,7 @@ invalid bids.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract BlindAuction {
struct Bid {

View File

@ -143,7 +143,7 @@ The full contract
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract ReceiverPays {
address owner = msg.sender;
@ -340,7 +340,7 @@ The full contract
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract SimplePaymentChannel {
address payable public sender; // The account sending payments.

View File

@ -20,7 +20,7 @@ and the sum of all balances is an invariant across the lifetime of the contract.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.5.0 <0.8.0;
pragma solidity >=0.5.0 <0.9.0;
library Balances {
function move(mapping(address => uint256) storage balances, address from, address to, uint amount) internal {

View File

@ -26,7 +26,7 @@ you can use state machine-like constructs inside a contract.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract Purchase {
uint public value;

View File

@ -33,7 +33,7 @@ of votes.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
/// @title Voting with delegation.
contract Ballot {

View File

@ -72,7 +72,7 @@ the position of ``data[4][9].b`` is at ``keccak256(uint256(9) . keccak256(uint25
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
contract C {
@ -173,7 +173,7 @@ value and reference types, types that are encoded packed, and nested types.
.. code::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
contract A {
struct S {
uint128 a;

View File

@ -18,7 +18,7 @@ Storage Example
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.8.0;
pragma solidity >=0.4.16 <0.9.0;
contract SimpleStorage {
uint storedData;
@ -83,7 +83,7 @@ registering with a username and password, all you need is an Ethereum keypair.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.5.99 <0.8.0;
pragma solidity >0.5.99 <0.9.0;
contract Coin {
// The keyword "public" makes variables

View File

@ -317,7 +317,7 @@ for the two function parameters and two return variables.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.21 <0.8.0;
pragma solidity >=0.4.21 <0.9.0;
/** @title Shape calculator. */
contract ShapeCalculator {

View File

@ -49,7 +49,7 @@ The following example shows a contract and a function using all available tags.
.. code:: Solidity
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.10 <0.8.0;
pragma solidity >0.6.10 <0.9.0;
/// @title A simulator for trees
/// @author Larry A. Gardner

View File

@ -59,7 +59,7 @@ complete contract):
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
// THIS CONTRACT CONTAINS A BUG - DO NOT USE
contract Fund {
@ -83,7 +83,7 @@ as it uses ``call`` which forwards all remaining gas by default:
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.2 <0.8.0;
pragma solidity >=0.6.2 <0.9.0;
// THIS CONTRACT CONTAINS A BUG - DO NOT USE
contract Fund {
@ -103,7 +103,7 @@ outlined further below:
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.11 <0.8.0;
pragma solidity >=0.4.11 <0.9.0;
contract Fund {
/// @dev Mapping of ether shares of the contract.
@ -201,7 +201,7 @@ Never use tx.origin for authorization. Let's say you have a wallet contract like
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
// THIS CONTRACT CONTAINS A BUG - DO NOT USE
contract TxUserWallet {
@ -222,7 +222,7 @@ Now someone tricks you into sending Ether to the address of this attack wallet:
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
interface TxUserWallet {
function transferTo(address payable dest, uint amount) external;
@ -283,7 +283,7 @@ field of a ``struct`` that is the base type of a dynamic storage array. The
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.8.0;
pragma solidity >=0.6.0 <0.9.0;
contract Map {
mapping (uint => uint)[] array;

View File

@ -27,7 +27,7 @@ storage.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
contract SimpleStorage {
uint storedData; // State variable
@ -50,7 +50,7 @@ contracts.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.7.0 <0.8.0;
pragma solidity >0.7.0 <0.9.0;
contract SimpleAuction {
function bid() public payable { // Function
@ -84,7 +84,7 @@ Like functions, modifiers can be :ref:`overridden <modifier-overriding>`.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.8.0;
pragma solidity >=0.4.22 <0.9.0;
contract Purchase {
address public seller;
@ -112,7 +112,7 @@ Events are convenience interfaces with the EVM logging facilities.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.21 <0.8.0;
pragma solidity >=0.4.21 <0.9.0;
contract SimpleAuction {
event HighestBidIncreased(address bidder, uint amount); // Event
@ -137,7 +137,7 @@ Structs are custom defined types that can group several variables (see
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
contract Ballot {
struct Voter { // Struct
@ -159,7 +159,7 @@ Enums can be used to create custom types with a finite set of 'constant values'
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
contract Purchase {
enum State { Created, Locked, Inactive } // Enum

View File

@ -56,7 +56,7 @@ Surround top level declarations in solidity source with two blank lines.
Yes::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
contract A {
// ...
@ -75,7 +75,7 @@ Yes::
No::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
contract A {
// ...
@ -95,7 +95,7 @@ Blank lines may be omitted between groups of related one-liners (such as stub fu
Yes::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.8.0;
pragma solidity >=0.6.0 <0.9.0;
abstract contract A {
function spam() public virtual pure;
@ -116,7 +116,7 @@ Yes::
No::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.8.0;
pragma solidity >=0.6.0 <0.9.0;
abstract contract A {
function spam() virtual pure public;
@ -251,7 +251,7 @@ Import statements should always be placed at the top of the file.
Yes::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
import "./Owned.sol";
@ -266,7 +266,7 @@ Yes::
No::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
contract A {
// ...
@ -300,7 +300,7 @@ Within a grouping, place the ``view`` and ``pure`` functions last.
Yes::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract A {
constructor() {
@ -337,7 +337,7 @@ Yes::
No::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract A {
@ -445,7 +445,7 @@ should:
Yes::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
contract Coin {
struct Bank {
@ -457,7 +457,7 @@ Yes::
No::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
contract Coin
{
@ -758,7 +758,7 @@ manner as modifiers if the function declaration is long or hard to read.
Yes::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
// Base contracts just to make this compile
contract B {
@ -790,7 +790,7 @@ Yes::
No::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
// Base contracts just to make this compile
@ -1012,7 +1012,7 @@ As shown in the example below, if the contract name is ``Congress`` and the libr
Yes::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
// Owned.sol
@ -1036,7 +1036,7 @@ Yes::
and in ``Congress.sol``::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
import "./Owned.sol";
@ -1048,7 +1048,7 @@ and in ``Congress.sol``::
No::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
// owned.sol
@ -1153,7 +1153,7 @@ For example, the contract from :ref:`a simple smart contract <simple-smart-contr
added looks like the one below::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.8.0;
pragma solidity >=0.4.16 <0.9.0;
/// @author The Solidity Team

View File

@ -43,7 +43,7 @@ contract that returns the value at the specified address.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
contract MappingExample {
mapping(address => uint) public balances;
@ -69,7 +69,7 @@ The example below uses ``_allowances`` to record the amount someone else is allo
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.8.0;
pragma solidity >=0.4.22 <0.9.0;
contract MappingExample {
@ -124,7 +124,7 @@ the ``sum`` function iterates over to sum all the values.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.8.0;
pragma solidity >=0.6.0 <0.9.0;
struct IndexValue { uint keyIndex; uint value; }
struct KeyFlag { uint key; bool deleted; }

View File

@ -43,7 +43,7 @@ value it referred to previously.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
contract DeleteExample {
uint data;

View File

@ -63,7 +63,7 @@ Data locations are not only relevant for persistency of data, but also for the s
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.5.0 <0.8.0;
pragma solidity >=0.5.0 <0.9.0;
contract C {
// The data location of x is storage.
@ -174,7 +174,7 @@ or create a new memory array and copy every element.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.8.0;
pragma solidity >=0.4.16 <0.9.0;
contract C {
function f(uint len) public pure {
@ -206,7 +206,7 @@ the first element to ``uint``.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.8.0;
pragma solidity >=0.4.16 <0.9.0;
contract C {
function f() public pure {
@ -223,7 +223,7 @@ memory arrays, i.e. the following is not possible:
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
// This will not compile.
contract C {
@ -243,7 +243,7 @@ individual elements:
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
contract C {
function f() public pure {
@ -301,7 +301,7 @@ Array Members
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.8.0;
pragma solidity >=0.6.0 <0.9.0;
contract ArrayContract {
uint[2**20] m_aLotOfIntegers;
@ -434,7 +434,7 @@ Array slices are useful to ABI-decode secondary data passed in function paramete
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
contract Proxy {
/// @dev Address of the client contract managed by proxy i.e., this contract
@ -478,7 +478,7 @@ shown in the following example:
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.0 <0.8.0;
pragma solidity >=0.6.0 <0.9.0;
// Defines a new type with two fields.
// Declaring a struct outside of a contract allows

View File

@ -561,7 +561,7 @@ subsequent unsigned integer values starting from ``0``.
::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.8.0;
pragma solidity >=0.4.16 <0.9.0;
contract test {
enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill }
@ -674,7 +674,7 @@ External (or public) functions have the following members:
Example that shows how to use the members::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.6.4 <0.8.0;
pragma solidity >=0.6.4 <0.9.0;
contract Example {
function f() public payable returns (bytes4) {
@ -690,7 +690,7 @@ Example that shows how to use the members::
Example that shows how to use internal function types::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.16 <0.8.0;
pragma solidity >=0.4.16 <0.9.0;
library ArrayUtils {
// internal functions can be used in internal library functions because
@ -748,7 +748,7 @@ Example that shows how to use internal function types::
Another example that uses external function types::
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.8.0;
pragma solidity >=0.4.22 <0.9.0;
contract Oracle {

View File

@ -693,7 +693,7 @@ have to be updated manually.)
.. code-block:: Solidity
pragma solidity >0.6.99 <0.8.0;
pragma solidity >0.6.99 <0.9.0;
// SPDX-License-Identifier: GPL-3.0
abstract contract C {
// FIXME: remove constructor visibility and make the contract abstract

View File

@ -43,7 +43,7 @@ namespace solidity::frontend::test
namespace
{
static char const* registrarCode = R"DELIMITER(
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
abstract contract NameRegister {
function addr(string memory _name) public virtual view returns (address o_owner);

View File

@ -55,7 +55,7 @@ static char const* registrarCode = R"DELIMITER(
// @authors:
// Gav Wood <g@ethdev.com>
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
abstract contract Registrar {
event Changed(string indexed name);

View File

@ -56,7 +56,7 @@ static char const* walletCode = R"DELIMITER(
// some number (specified in constructor) of the set of owners (specified in the constructor, modifiable) before the
// interior is executed.
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
contract multiowned {

View File

@ -1,4 +1,4 @@
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
contract InvalidTest {

View File

@ -1,4 +1,4 @@
pragma solidity >=0.4.0 <0.8.0;
pragma solidity >=0.4.0 <0.9.0;
contract ERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);