aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/assembly.rst27
-rw-r--r--docs/bugs.json19
-rw-r--r--docs/bugs_by_version.json69
-rw-r--r--docs/contracts.rst4
-rw-r--r--docs/control-structures.rst13
-rw-r--r--docs/index.rst5
-rw-r--r--docs/installing-solidity.rst14
-rw-r--r--docs/miscellaneous.rst5
-rw-r--r--docs/security-considerations.rst5
-rw-r--r--docs/solidity-by-example.rst23
-rw-r--r--docs/types.rst15
-rw-r--r--docs/units-and-global-variables.rst15
12 files changed, 170 insertions, 44 deletions
diff --git a/docs/assembly.rst b/docs/assembly.rst
index 4e665b7e..bdb708a9 100644
--- a/docs/assembly.rst
+++ b/docs/assembly.rst
@@ -96,6 +96,31 @@ you really know what you are doing.
}
}
}
+
+ // Same as above, but accomplish the entire code within inline assembly.
+ function sumPureAsm(uint[] _data) returns (uint o_sum) {
+ assembly {
+ // Load the length (first 32 bytes)
+ let len := mload(_data)
+
+ // Skip over the length field.
+ //
+ // Keep temporary variable so it can be incremented in place.
+ //
+ // NOTE: incrementing _data would result in an unusable
+ // _data variable after this assembly block
+ let data := add(_data, 0x20)
+
+ // Iterate until the bound is not met.
+ for
+ { let end := add(data, len) }
+ lt(data, end)
+ { data := add(data, 0x20) }
+ {
+ o_sum := add(o_sum, mload(data))
+ }
+ }
+ }
}
@@ -125,7 +150,7 @@ following list can be used as a reference of its opcodes.
If an opcode takes arguments (always from the top of the stack), they are given in parentheses.
Note that the order of arguments can be seen to be reversed in non-functional style (explained below).
Opcodes marked with ``-`` do not push an item onto the stack, those marked with ``*`` are
-special and all others push exactly one item onte the stack.
+special and all others push exactly one item onto the stack.
In the following, ``mem[a...b)`` signifies the bytes of memory starting at position ``a`` up to
(excluding) position ``b`` and ``storage[p]`` signifies the storage contents at position ``p``.
diff --git a/docs/bugs.json b/docs/bugs.json
index a0c0e7c4..ac322a48 100644
--- a/docs/bugs.json
+++ b/docs/bugs.json
@@ -1,7 +1,22 @@
[
{
+ "name": "DelegateCallReturnValue",
+ "summary": "The low-level .delegatecall() does not return the execution outcome, but converts the value returned by the functioned called to a boolean instead.",
+ "description": "The return value of the low-level .delegatecall() function is taken from a position in memory, where the call data or the return data resides. This value is interpreted as a boolean and put onto the stack. This means if the called function returns at least 32 zero bytes, .delegatecall() returns false even if the call was successuful.",
+ "introduced": "0.3.0",
+ "fixed": "0.4.15",
+ "severity": "low"
+ },
+ {
+ "name": "ECRecoverMalformedInput",
+ "summary": "The ecrecover() builtin can return garbage for malformed input.",
+ "description": "The ecrecover precompile does not properly signal failure for malformed input (especially in the 'v' argument) and thus the Solidity function can return data that was previously present in the return area in memory.",
+ "fixed": "0.4.14",
+ "severity": "medium"
+ },
+ {
"name": "SkipEmptyStringLiteral",
- "summary": "If \"\" is used in a function call, the following function arguments will not be correctly passed to the function.",
+ "summary": "If \"\" is used in a function call, the following function arguments will not be correctly passed to the function.",
"description": "If the empty string literal \"\" is used as an argument in a function call, it is skipped by the encoder. This has the effect that the encoding of all arguments following this is shifted left by 32 bytes and thus the function call data is corrupted.",
"fixed": "0.4.12",
"severity": "low"
@@ -107,4 +122,4 @@
"severity": "high",
"fixed": "0.3.0"
}
-] \ No newline at end of file
+]
diff --git a/docs/bugs_by_version.json b/docs/bugs_by_version.json
index d6802eec..33f7bae9 100644
--- a/docs/bugs_by_version.json
+++ b/docs/bugs_by_version.json
@@ -1,6 +1,7 @@
{
"0.1.0": {
"bugs": [
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -16,6 +17,7 @@
},
"0.1.1": {
"bugs": [
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -31,6 +33,7 @@
},
"0.1.2": {
"bugs": [
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -46,6 +49,7 @@
},
"0.1.3": {
"bugs": [
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -61,6 +65,7 @@
},
"0.1.4": {
"bugs": [
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -76,6 +81,7 @@
},
"0.1.5": {
"bugs": [
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -91,6 +97,7 @@
},
"0.1.6": {
"bugs": [
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -107,6 +114,7 @@
},
"0.1.7": {
"bugs": [
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -123,6 +131,7 @@
},
"0.2.0": {
"bugs": [
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -139,6 +148,7 @@
},
"0.2.1": {
"bugs": [
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -155,6 +165,7 @@
},
"0.2.2": {
"bugs": [
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -171,6 +182,8 @@
},
"0.3.0": {
"bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -186,6 +199,8 @@
},
"0.3.1": {
"bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -200,6 +215,8 @@
},
"0.3.2": {
"bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -214,6 +231,8 @@
},
"0.3.3": {
"bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -227,6 +246,8 @@
},
"0.3.4": {
"bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -240,6 +261,8 @@
},
"0.3.5": {
"bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -253,6 +276,8 @@
},
"0.3.6": {
"bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -264,6 +289,8 @@
},
"0.4.0": {
"bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -275,6 +302,8 @@
},
"0.4.1": {
"bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -286,6 +315,8 @@
},
"0.4.10": {
"bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction"
],
@@ -293,20 +324,40 @@
},
"0.4.11": {
"bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral"
],
"released": "2017-05-03"
},
"0.4.12": {
- "bugs": [],
+ "bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput"
+ ],
"released": "2017-07-03"
},
"0.4.13": {
- "bugs": [],
+ "bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput"
+ ],
"released": "2017-07-06"
},
+ "0.4.14": {
+ "bugs": [
+ "DelegateCallReturnValue"
+ ],
+ "released": "2017-07-31"
+ },
+ "0.4.15": {
+ "bugs": [],
+ "released": "2017-08-08"
+ },
"0.4.2": {
"bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -317,6 +368,8 @@
},
"0.4.3": {
"bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -326,6 +379,8 @@
},
"0.4.4": {
"bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored"
@@ -334,6 +389,8 @@
},
"0.4.5": {
"bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored",
@@ -343,6 +400,8 @@
},
"0.4.6": {
"bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction",
"IdentityPrecompileReturnIgnored"
@@ -351,6 +410,8 @@
},
"0.4.7": {
"bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction"
],
@@ -358,6 +419,8 @@
},
"0.4.8": {
"bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction"
],
@@ -365,6 +428,8 @@
},
"0.4.9": {
"bugs": [
+ "DelegateCallReturnValue",
+ "ECRecoverMalformedInput",
"SkipEmptyStringLiteral",
"ConstantOptimizerSubtraction"
],
diff --git a/docs/contracts.rst b/docs/contracts.rst
index 11e674d1..da797702 100644
--- a/docs/contracts.rst
+++ b/docs/contracts.rst
@@ -84,7 +84,7 @@ This means that cyclic creation dependencies are impossible.
// State variables are accessed via their name
// and not via e.g. this.owner. This also applies
// to functions and especially in the constructors,
- // you can only call them like that ("internall"),
+ // you can only call them like that ("internally"),
// because the contract itself does not exist yet.
owner = msg.sender;
// We do an explicit type conversion from `address`
@@ -246,7 +246,7 @@ In the following example, ``D``, can call ``c.getData()`` to retrieve the value
}
.. index:: ! getter;function, ! function;getter
-.. _getter_functions:
+.. _getter-functions:
Getter Functions
================
diff --git a/docs/control-structures.rst b/docs/control-structures.rst
index 128e6fae..796e9238 100644
--- a/docs/control-structures.rst
+++ b/docs/control-structures.rst
@@ -381,13 +381,11 @@ Error handling: Assert, Require, Revert and Exceptions
Solidity uses state-reverting exceptions to handle errors. Such an exception will undo all changes made to the
state in the current call (and all its sub-calls) and also flag an error to the caller.
The convenience functions ``assert`` and ``require`` can be used to check for conditions and throw an exception
-if the condition is not met. The difference between the two is that ``assert`` should only be used for internal errors
-and ``require`` should be used to check external conditions (invalid inputs or errors in external components).
-The idea behind that is that analysis tools can check your contract and try to come up with situations and
-series of function calls that will reach a failing assertion. If this is possible, this means there is a bug
-in your contract you should fix.
+if the condition is not met. The ``assert`` function should only be used to test for internal errors, and to check invariants.
+The ``require`` function should be used to ensure valid conditions, such as inputs, or contract state variables are met, or to validate return values from calls to external contracts.
+If used properly, analysis tools can evaluate your contract to identify the conditions and function calls which will reach a failing ``assert``. Properly functioning code should never reach a failing assert statement; if this happens there is a bug in your contract which you should fix.
-There are two other ways to trigger execptions: The ``revert`` function can be used to flag an error and
+There are two other ways to trigger exceptions: The ``revert`` function can be used to flag an error and
revert the current call. In the future it might be possible to also include details about the error
in a call to ``revert``. The ``throw`` keyword can also be used as an alternative to ``revert()``.
@@ -395,6 +393,9 @@ When exceptions happen in a sub-call, they "bubble up" (i.e. exceptions are reth
and the low-level functions ``call``, ``delegatecall`` and ``callcode`` -- those return ``false`` in case
of an exception instead of "bubbling up".
+.. warning::
+ The low-level ``call``, ``delegatecall`` and ``callcode`` will return success if the calling account is non-existent, as part of the design of EVM. Existence must be checked prior to calling if desired.
+
Catching exceptions is not yet possible.
In the following example, you can see how ``require`` can be used to easily check conditions on inputs
diff --git a/docs/index.rst b/docs/index.rst
index 3cdda62d..dea11a86 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -41,9 +41,6 @@ Available Solidity Integrations
* `Remix <https://remix.ethereum.org/>`_
Browser-based IDE with integrated compiler and Solidity runtime environment without server-side components.
-* `Ethereum Studio <https://live.ether.camp/>`_
- Specialized web IDE that also provides shell access to a complete Ethereum environment.
-
* `IntelliJ IDEA plugin <https://plugins.jetbrains.com/plugin/9475-intellij-solidity>`_
Solidity plugin for IntelliJ IDEA (and all other JetBrains IDEs)
@@ -82,6 +79,8 @@ Discontinued:
* `Mix IDE <https://github.com/ethereum/mix/>`_
Qt based IDE for designing, debugging and testing solidity smart contracts.
+* `Ethereum Studio <https://live.ether.camp/>`_
+ Specialized web IDE that also provides shell access to a complete Ethereum environment.
Solidity Tools
--------------
diff --git a/docs/installing-solidity.rst b/docs/installing-solidity.rst
index 9b5ba9f2..35eb2d93 100644
--- a/docs/installing-solidity.rst
+++ b/docs/installing-solidity.rst
@@ -56,7 +56,7 @@ repository contains potentially unstable changes in the develop branch.
docker run ethereum/solc:stable solc --version
-Currenty, the docker image only contains the compiler executable,
+Currently, the docker image only contains the compiler executable,
so you have to do some additional work to link in the source and
output directories.
@@ -82,6 +82,18 @@ If you want to use the cutting edge developer version:
sudo add-apt-repository ppa:ethereum/ethereum-dev
sudo apt-get update
sudo apt-get install solc
+
+We are also releasing a `snap package <https://snapcraft.io/>`_, which is installable in all the `supported Linux distros <https://snapcraft.io/docs/core/install>`_. To install the latest stable version of solc:
+
+.. code:: bash
+
+ sudo snap install solc
+
+Or if you want to help testing the unstable solc with the most recent changes from the development branch:
+
+.. code:: bash
+
+ sudo snap install solc --edge
Arch Linux also has packages, albeit limited to the latest development version:
diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst
index 1fcdb2fc..e364bee7 100644
--- a/docs/miscellaneous.rst
+++ b/docs/miscellaneous.rst
@@ -469,7 +469,7 @@ Global Variables
- ``require(bool condition)``: abort execution and revert state changes if condition is ``false`` (use for malformed input or error in external component)
- ``revert()``: abort execution and revert state changes
- ``keccak256(...) returns (bytes32)``: compute the Ethereum-SHA-3 (Keccak-256) hash of the (tightly packed) arguments
-- ``sha3(...) returns (bytes32)``: an alias to `keccak256()`
+- ``sha3(...) returns (bytes32)``: an alias to `keccak256`
- ``sha256(...) returns (bytes32)``: compute the SHA-256 hash of the (tightly packed) arguments
- ``ripemd160(...) returns (bytes20)``: compute the RIPEMD-160 hash of the (tightly packed) arguments
- ``ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address)``: recover address associated with the public key from elliptic curve signature, return zero on error
@@ -478,6 +478,7 @@ Global Variables
- ``this`` (current contract's type): the current contract, explicitly convertible to ``address``
- ``super``: the contract one level higher in the inheritance hierarchy
- ``selfdestruct(address recipient)``: destroy the current contract, sending its funds to the given address
+- ``suicide(address recipieint)``: an alias to `selfdestruct``
- ``<address>.balance`` (``uint256``): balance of the :ref:`address` in Wei
- ``<address>.send(uint256 amount) returns (bool)``: send given amount of Wei to :ref:`address`, returns ``false`` on failure
- ``<address>.transfer(uint256 amount)``: send given amount of Wei to :ref:`address`, throws on failure
@@ -515,7 +516,7 @@ Reserved Keywords
These keywords are reserved in Solidity. They might become part of the syntax in the future:
-``abstract``, ``after``, ``case``, ``catch``, ``default``, ``final``, ``in``, ``inline``, ``interface``, ``let``, ``match``, ``null``,
+``abstract``, ``after``, ``case``, ``catch``, ``default``, ``final``, ``in``, ``inline``, ``let``, ``match``, ``null``,
``of``, ``pure``, ``relocatable``, ``static``, ``switch``, ``try``, ``type``, ``typeof``, ``view``.
Language Grammar
diff --git a/docs/security-considerations.rst b/docs/security-considerations.rst
index 658c12b2..6586cb5f 100644
--- a/docs/security-considerations.rst
+++ b/docs/security-considerations.rst
@@ -14,7 +14,7 @@ the source code is often available.
Of course you always have to consider how much is at stake:
You can compare a smart contract with a web service that is open to the
-public (and thus, also to malicous actors) and perhaps even open source.
+public (and thus, also to malicious actors) and perhaps even open source.
If you only store your grocery list on that web service, you might not have
to take too much care, but if you manage your bank account using that web service,
you should be more careful.
@@ -280,8 +280,7 @@ Formal Verification
Using formal verification, it is possible to perform an automated mathematical
proof that your source code fulfills a certain formal specification.
The specification is still formal (just as the source code), but usually much
-simpler. There is a prototype in Solidity that performs formal verification and
-it will be better documented soon.
+simpler.
Note that formal verification itself can only help you understand the
difference between what you did (the specification) and how you did it
diff --git a/docs/solidity-by-example.rst b/docs/solidity-by-example.rst
index e1fd4914..dde4495b 100644
--- a/docs/solidity-by-example.rst
+++ b/docs/solidity-by-example.rst
@@ -101,7 +101,7 @@ of votes.
/// Delegate your vote to the voter `to`.
function delegate(address to) {
// assigns reference
- Voter sender = voters[msg.sender];
+ Voter storage sender = voters[msg.sender];
require(!sender.voted);
// Self-delegation is not allowed.
@@ -141,7 +141,7 @@ of votes.
/// Give your vote (including votes delegated to you)
/// to proposal `proposals[proposal].name`.
function vote(uint proposal) {
- Voter sender = voters[msg.sender];
+ Voter storage sender = voters[msg.sender];
require(!sender.voted);
sender.voted = true;
sender.vote = proposal;
@@ -277,9 +277,9 @@ activate themselves.
if (highestBidder != 0) {
// Sending back the money by simply using
// highestBidder.send(highestBid) is a security risk
- // because it can be prevented by the caller by e.g.
- // raising the call stack to 1023. It is always safer
- // to let the recipients withdraw their money themselves.
+ // because it could execute an untrusted contract.
+ // It is always safer to let the recipients
+ // withdraw their money themselves.
pendingReturns[highestBidder] += highestBid;
}
highestBidder = msg.sender;
@@ -289,7 +289,7 @@ activate themselves.
/// Withdraw a bid that was overbid.
function withdraw() returns (bool) {
- var amount = pendingReturns[msg.sender];
+ uint amount = pendingReturns[msg.sender];
if (amount > 0) {
// It is important to set this to zero because the recipient
// can call this function again as part of the receiving call
@@ -491,8 +491,8 @@ high or low invalid bids.
}
/// Withdraw a bid that was overbid.
- function withdraw() returns (bool) {
- var amount = pendingReturns[msg.sender];
+ function withdraw() {
+ uint amount = pendingReturns[msg.sender];
if (amount > 0) {
// It is important to set this to zero because the recipient
// can call this function again as part of the receiving call
@@ -500,13 +500,8 @@ high or low invalid bids.
// conditions -> effects -> interaction).
pendingReturns[msg.sender] = 0;
- if (!msg.sender.send(amount)){
- // No need to call throw here, just reset the amount owing
- pendingReturns[msg.sender] = amount;
- return false;
- }
+ msg.sender.transfer(amount);
}
- return true;
}
/// End the auction and send the highest bid
diff --git a/docs/types.rst b/docs/types.rst
index 7085610a..403d032c 100644
--- a/docs/types.rst
+++ b/docs/types.rst
@@ -135,6 +135,9 @@ The ``.gas()`` option is available on all three methods, while the ``.value()``
All contracts inherit the members of address, so it is possible to query the balance of the
current contract using ``this.balance``.
+.. note::
+ The use of ``callcode`` is discouraged and will be removed in the future.
+
.. warning::
All these functions are low-level functions and should be used with care.
Specifically, any unknown contract might be malicious and if you call it, you
@@ -437,7 +440,8 @@ Another example that uses external function types::
}
}
-Note that lambda or inline functions are planned but not yet supported.
+.. note::
+ Lambda or inline functions are planned but not yet supported.
.. index:: ! type;reference, ! reference type, storage, memory, location, array, struct
@@ -740,7 +744,7 @@ shown in the following example:
}
function contribute(uint campaignID) payable {
- Campaign c = campaigns[campaignID];
+ Campaign storage c = campaigns[campaignID];
// Creates a new temporary memory struct, initialised with the given values
// and copies it over to storage.
// Note that you can also use Funder(msg.sender, msg.value) to initialise.
@@ -749,7 +753,7 @@ shown in the following example:
}
function checkGoalReached(uint campaignID) returns (bool reached) {
- Campaign c = campaigns[campaignID];
+ Campaign storage c = campaigns[campaignID];
if (c.amount < c.fundingGoal)
return false;
uint amount = c.amount;
@@ -816,9 +820,10 @@ for each ``_KeyType``, recursively.
}
contract MappingUser {
- address contractAddress = 0x42;
function f() returns (uint) {
- return MappingExample(contractAddress).balances(this);
+ MappingExample m = new MappingExample();
+ m.update(100);
+ return m.balances(this);
}
}
diff --git a/docs/units-and-global-variables.rst b/docs/units-and-global-variables.rst
index 7d21f065..64795306 100644
--- a/docs/units-and-global-variables.rst
+++ b/docs/units-and-global-variables.rst
@@ -35,7 +35,9 @@ These suffixes cannot be applied to variables. If you want to
interpret some input variable in e.g. days, you can do it in the following way::
function f(uint start, uint daysAfter) {
- if (now >= start + daysAfter * 1 days) { ... }
+ if (now >= start + daysAfter * 1 days) {
+ // ...
+ }
}
Special Variables and Functions
@@ -70,6 +72,7 @@ Block and Transaction Properties
``msg.value`` can change for every **external** function call.
This includes calls to library functions.
+.. note::
If you want to implement access restrictions in library functions using
``msg.sender``, you have to manually supply the value of
``msg.sender`` as an argument.
@@ -102,10 +105,10 @@ Mathematical and Cryptographic Functions
compute ``(x * y) % k`` where the multiplication is performed with arbitrary precision and does not wrap around at ``2**256``.
``keccak256(...) returns (bytes32)``:
compute the Ethereum-SHA-3 (Keccak-256) hash of the (tightly packed) arguments
-``sha3(...) returns (bytes32)``:
- alias to ``keccak256()``
``sha256(...) returns (bytes32)``:
compute the SHA-256 hash of the (tightly packed) arguments
+``sha3(...) returns (bytes32)``:
+ alias to ``keccak256``
``ripemd160(...) returns (bytes20)``:
compute RIPEMD-160 hash of the (tightly packed) arguments
``ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address)``:
@@ -157,6 +160,9 @@ For more information, see the section on :ref:`address`.
to make safe Ether transfers, always check the return value of ``send``, use ``transfer`` or even better:
Use a pattern where the recipient withdraws the money.
+.. note::
+ The use of ``callcode`` is discouraged and will be removed in the future.
+
.. index:: this, selfdestruct
Contract Related
@@ -168,5 +174,8 @@ Contract Related
``selfdestruct(address recipient)``:
destroy the current contract, sending its funds to the given :ref:`address`
+``suicide(address recipient)``:
+ alias to ``selfdestruct``
+
Furthermore, all functions of the current contract are callable directly including the current function.