aboutsummaryrefslogtreecommitdiffstats
path: root/docs/structure-of-a-contract.rst
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2016-09-06 21:59:49 +0800
committerGitHub <noreply@github.com>2016-09-06 21:59:49 +0800
commit453490cb61002622fadddf5838d29a8483f364ae (patch)
tree2d5ff5cddbf8fd73afe75a516998b9890b6cf86e /docs/structure-of-a-contract.rst
parent462fc84e530a6e740dfc8bb92bbd5ba82862cbb2 (diff)
parent183cd70c47e27f2cec34512757860193104f674b (diff)
downloaddexon-solidity-453490cb61002622fadddf5838d29a8483f364ae.tar.gz
dexon-solidity-453490cb61002622fadddf5838d29a8483f364ae.tar.zst
dexon-solidity-453490cb61002622fadddf5838d29a8483f364ae.zip
Merge pull request #1003 from winsvega/docs
add "pragma solidity ^0.4.0;" to code examples
Diffstat (limited to 'docs/structure-of-a-contract.rst')
-rw-r--r--docs/structure-of-a-contract.rst12
1 files changed, 12 insertions, 0 deletions
diff --git a/docs/structure-of-a-contract.rst b/docs/structure-of-a-contract.rst
index 79f78422..1036289a 100644
--- a/docs/structure-of-a-contract.rst
+++ b/docs/structure-of-a-contract.rst
@@ -20,6 +20,8 @@ State variables are values which are permanently stored in contract storage.
::
+ pragma solidity ^0.4.0;
+
contract SimpleStorage {
uint storedData; // State variable
// ...
@@ -38,6 +40,8 @@ Functions are the executable units of code within a contract.
::
+ pragma solidity ^0.4.0;
+
contract SimpleAuction {
function bid() { // Function
// ...
@@ -58,6 +62,8 @@ Function modifiers can be used to amend the semantics of functions in a declarat
::
+ pragma solidity ^0.4.0;
+
contract Purchase {
address public seller;
@@ -80,6 +86,8 @@ Events are convenience interfaces with the EVM logging facilities.
::
+ pragma solidity ^0.4.0;
+
contract SimpleAuction {
event HighestBidIncreased(address bidder, uint amount); // Event
@@ -102,6 +110,8 @@ Structs are custom defined types that can group several variables (see
::
+ pragma solidity ^0.4.0;
+
contract Ballot {
struct Voter { // Struct
uint weight;
@@ -121,6 +131,8 @@ Enums can be used to create custom types with a finite set of values (see
::
+ pragma solidity ^0.4.0;
+
contract Purchase {
enum State { Created, Locked, Inactive } // Enum
}