aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2016-08-26 23:01:38 +0800
committerGitHub <noreply@github.com>2016-08-26 23:01:38 +0800
commit83160d56f3827fce5394339937ffc9c588a3633e (patch)
tree69ef5d43658dcdf6e946a5c6c33ba4b22992ef9f /docs
parentd209e65b1d9ce3f49821970e96e027ba5243e386 (diff)
parent8c3b1334ae600f3995618556b59f6233b665ce33 (diff)
downloaddexon-solidity-83160d56f3827fce5394339937ffc9c588a3633e.tar
dexon-solidity-83160d56f3827fce5394339937ffc9c588a3633e.tar.gz
dexon-solidity-83160d56f3827fce5394339937ffc9c588a3633e.tar.bz2
dexon-solidity-83160d56f3827fce5394339937ffc9c588a3633e.tar.lz
dexon-solidity-83160d56f3827fce5394339937ffc9c588a3633e.tar.xz
dexon-solidity-83160d56f3827fce5394339937ffc9c588a3633e.tar.zst
dexon-solidity-83160d56f3827fce5394339937ffc9c588a3633e.zip
Merge pull request #953 from Denton-L/fallback-stuff
Write about what fallback functions cannot do
Diffstat (limited to 'docs')
-rw-r--r--docs/contracts.rst45
1 files changed, 27 insertions, 18 deletions
diff --git a/docs/contracts.rst b/docs/contracts.rst
index 85592f5d..dfdcaf18 100644
--- a/docs/contracts.rst
+++ b/docs/contracts.rst
@@ -211,18 +211,18 @@ storage and is not able to call ``f``. Contract ``E`` is derived from ``C`` and
contract D {
function readData() {
- C c = new C();
- local = c.f(7); // error: member "f" is not visible
- c.setData(3);
- uint local = c.getData();
- local = c.compute(3,5); // error: member "compute" is not visible
- }
+ C c = new C();
+ local = c.f(7); // error: member "f" is not visible
+ c.setData(3);
+ uint local = c.getData();
+ local = c.compute(3,5); // error: member "compute" is not visible
+ }
}
contract E is C {
function g() {
- C c = new C();
- uint val = compute(3,5); // acces to internal member (from derivated to parent contract)
+ C c = new C();
+ uint val = compute(3,5); // acces to internal member (from derivated to parent contract)
}
}
@@ -244,12 +244,12 @@ be done at declaration.
contract C {
uint public data = 42;
}
-
+
contract Caller {
- C c = new C();
- function f() {
- uint local = c.data();
- }
+ C c = new C();
+ function f() {
+ uint local = c.data();
+ }
}
The accessor functions have external visibility. If the
@@ -260,11 +260,11 @@ it is evaluated as state variable and if it is accessed externally
::
contract C {
- uint public data;
- function x() {
- data = 3; // internal access
- uint val = this.data(); // external access
- }
+ uint public data;
+ function x() {
+ data = 3; // internal access
+ uint val = this.data(); // external access
+ }
}
The next example is a bit more complex:
@@ -435,6 +435,15 @@ Ether (without data). In such a context, there is very little gas available to
the function call (to be precise, 2300 gas), so it is important to make fallback functions as cheap as
possible.
+In particular, the following operations will consume more gas than the stipend provided to a fallback function:
+
+- Writing to storage
+- Creating a contract
+- Calling an external function which consumes a large amount of gas
+- Sending Ether
+
+Please ensure you test your fallback function thoroughly to ensure the execution cost is less than 2300 gas before deploying a contract.
+
::
contract Test {