aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-08-25 18:12:26 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-08-25 19:49:53 +0800
commit2af949baaa31c328060008fe5b4dc251657f3d9d (patch)
treee2565792d34241fc2d74016e1848887497cfb027 /docs
parentf791ca3957e30ba89763d3cf3327ed3e58d21b15 (diff)
downloaddexon-solidity-2af949baaa31c328060008fe5b4dc251657f3d9d.tar.gz
dexon-solidity-2af949baaa31c328060008fe5b4dc251657f3d9d.tar.zst
dexon-solidity-2af949baaa31c328060008fe5b4dc251657f3d9d.zip
Explain the limitations of view and pure
Diffstat (limited to 'docs')
-rw-r--r--docs/contracts.rst18
1 files changed, 18 insertions, 0 deletions
diff --git a/docs/contracts.rst b/docs/contracts.rst
index 973386d5..ef09d935 100644
--- a/docs/contracts.rst
+++ b/docs/contracts.rst
@@ -469,6 +469,17 @@ View Functions
Functions can be declared ``view`` in which case they promise not to modify the state.
+The following statements are considered modifying the state:
+
+#. Writing to state variables.
+#. :ref:`Emitting events. <events>`.
+#. :ref:`Creating other contracts <creating-contracts>`.
+#. Using ``selfdestruct``.
+#. Sending Ether via calls.
+#. Calling any function not marked ``view`` or ``pure``.
+#. Using low-level calls.
+#. Using inline assembly that contains certain opcodes.
+
::
pragma solidity ^0.4.16;
@@ -496,6 +507,13 @@ Pure Functions
Functions can be declared ``pure`` in which case they promise not to read from or modify the state.
+In addition to the list of state modifying statements explained above, the following are considered reading from the state:
+#. Reading from state variables.
+#. Accessing ``this.balance`` or ``<address>.balance``.
+#. Accessing any of the members of ``block``, ``tx``, ``msg`` (with the exception of ``msg.sig`` and ``msg.data``).
+#. Calling any function not marked ``pure``.
+#. Using inline assembly that contains certain opcodes.
+
::
pragma solidity ^0.4.16;