mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Removed trailing whitespace
This commit is contained in:
parent
4b9e9cad56
commit
d4ad3231a2
@ -203,7 +203,7 @@ function finishes.
|
||||
nextStage();
|
||||
// The other stages transition by transaction
|
||||
}
|
||||
|
||||
|
||||
// Order of the modifiers matters here!
|
||||
function bid()
|
||||
timedTransitions
|
||||
|
@ -139,10 +139,10 @@ with `c.someMethod.sendTransaction({from:eth.accounts[x], gas: 1000000});`
|
||||
That is, because they can change state, they have to have a gas
|
||||
payment sent along to get the work done.
|
||||
|
||||
Get a contract to return its funds to you (not using selfdestruct(...)).
|
||||
Get a contract to return its funds to you (not using selfdestruct(...)).
|
||||
========================================================================
|
||||
|
||||
This example demonstrates how to send funds from a contract to an address.
|
||||
This example demonstrates how to send funds from a contract to an address.
|
||||
|
||||
See `endowment_retriever <https://github.com/fivedogit/solidity-baby-steps/blob/master/contracts/30_endowment_retriever.sol>`_.
|
||||
|
||||
@ -175,7 +175,7 @@ datastructure on top of it, for example the `iterable mapping <https://github.co
|
||||
Can I put arrays inside of a mapping? How do I make a mapping of a mapping?
|
||||
===========================================================================
|
||||
|
||||
Mappings are already syntactically similar to arrays as they are, therefore it doesn't make much sense to store an array in them. Rather what you should do is create a mapping of a mapping.
|
||||
Mappings are already syntactically similar to arrays as they are, therefore it doesn't make much sense to store an array in them. Rather what you should do is create a mapping of a mapping.
|
||||
|
||||
An example of this would be::
|
||||
|
||||
@ -278,7 +278,7 @@ Is a constructor required?
|
||||
|
||||
No. If there is no constructor, a generic one without arguments and no actions will be used.
|
||||
|
||||
Are timestamps (now, block.timestamp) reliable?
|
||||
Are timestamps (now, block.timestamp) reliable?
|
||||
===============================================
|
||||
|
||||
This depends on what you mean by "reliable".
|
||||
@ -327,7 +327,7 @@ should implement the fallback function as
|
||||
`function() { throw; }`
|
||||
|
||||
this will cause all transactions to this contract that do not call an
|
||||
existing function to be reverted, so that all Ether is sent back.
|
||||
existing function to be reverted, so that all Ether is sent back.
|
||||
|
||||
Another use of the fallback function is to e.g. register that your
|
||||
contract received ether by using an event.
|
||||
@ -347,7 +347,7 @@ by `msg.data`.
|
||||
Can state variables be initialized in-line?
|
||||
===========================================
|
||||
|
||||
Yes, this is possible for all types (even for structs). However, for arrays it
|
||||
Yes, this is possible for all types (even for structs). However, for arrays it
|
||||
should be noted that you must declare them as static memory arrays.
|
||||
|
||||
Examples::
|
||||
@ -360,7 +360,7 @@ Examples::
|
||||
|
||||
S public x = S(1, 2);
|
||||
string name = "Ada";
|
||||
string[4] memory AdaArr = ["This", "is", "an", "array"];
|
||||
string[4] memory AdaArr = ["This", "is", "an", "array"];
|
||||
}
|
||||
|
||||
|
||||
@ -726,7 +726,7 @@ In this example::
|
||||
Can a contract function accept a two-dimensional array?
|
||||
=======================================================
|
||||
|
||||
This is not yet implemented for external calls and dynamic arrays -
|
||||
This is not yet implemented for external calls and dynamic arrays -
|
||||
you can only use one level of dynamic arrays.
|
||||
|
||||
What is the relationship between bytes32 and string? Why is it that ‘bytes32 somevar = "stringliteral";’ works and what does the saved 32-byte hex value mean?
|
||||
|
@ -59,13 +59,13 @@ Set up Homebrew:
|
||||
|
||||
brew update
|
||||
brew upgrade
|
||||
|
||||
|
||||
brew install boost --c++11 # this takes a while
|
||||
brew install cmake cryptopp miniupnpc leveldb gmp libmicrohttpd libjson-rpc-cpp
|
||||
brew install cmake cryptopp miniupnpc leveldb gmp libmicrohttpd libjson-rpc-cpp
|
||||
# For Mix IDE and Alethzero only
|
||||
brew install xz d-bus
|
||||
brew install homebrew/versions/v8-315
|
||||
brew install llvm --HEAD --with-clang
|
||||
brew install llvm --HEAD --with-clang
|
||||
brew install qt5 --with-d-bus # add --verbose if long waits with a stale screen drive you crazy as well
|
||||
|
||||
Ubuntu
|
||||
@ -112,7 +112,7 @@ For Ubuntu 15.10 (Wily Werewolf) or newer, use the following command instead:
|
||||
.. code-block:: bash
|
||||
|
||||
sudo apt-get -y install build-essential git cmake libboost-all-dev libgmp-dev libleveldb-dev libminiupnpc-dev libreadline-dev libncurses5-dev libcurl4-openssl-dev libcryptopp-dev libjsonrpccpp-dev libmicrohttpd-dev libjsoncpp-dev libedit-dev libz-dev
|
||||
|
||||
|
||||
The reason for the change is that `libjsonrpccpp-dev` is available in the universe repository for newer versions of Ubuntu.
|
||||
|
||||
Building
|
||||
@ -128,7 +128,7 @@ they relate only to Alethzero and Mix
|
||||
./webthree-helpers/scripts/ethupdate.sh --no-push --simple-pull --project solidity # update Solidity repo
|
||||
./webthree-helpers/scripts/ethbuild.sh --no-git --project solidity --all --cores 4 -DEVMJIT=0 # build Solidity and others
|
||||
#enabling DEVMJIT on OS X will not build
|
||||
#feel free to enable it on Linux
|
||||
#feel free to enable it on Linux
|
||||
|
||||
If you opted to install Alethzero and Mix:
|
||||
|
||||
|
@ -15,7 +15,7 @@ a lot of Solidity's features. It implements a voting
|
||||
contract. Of course, the main problems of electronic
|
||||
voting is how to assign voting rights to the correct
|
||||
persons and how to prevent manipulation. We will not
|
||||
solve all problems here, but at least we will show
|
||||
solve all problems here, but at least we will show
|
||||
how delegated voting can be done so that vote counting
|
||||
is **automatic and completely transparent** at the
|
||||
same time.
|
||||
@ -125,7 +125,7 @@ of votes.
|
||||
Voter delegate = voters[to];
|
||||
if (delegate.voted) {
|
||||
// If the delegate already voted,
|
||||
// directly add to the number of votes
|
||||
// directly add to the number of votes
|
||||
proposals[delegate.vote].voteCount += sender.weight;
|
||||
}
|
||||
else {
|
||||
|
@ -26,7 +26,7 @@ State variables are values which are permanently stored in contract storage.
|
||||
}
|
||||
|
||||
See the :ref:`types` section for valid state variable types and
|
||||
:ref:`visibility-and-accessors` for possible choices for
|
||||
:ref:`visibility-and-accessors` for possible choices for
|
||||
visibility.
|
||||
|
||||
.. _structure-functions:
|
||||
@ -46,7 +46,7 @@ Functions are the executable units of code within a contract.
|
||||
|
||||
:ref:`function-calls` can happen internally or externally
|
||||
and have different levels of visibility (:ref:`visibility-and-accessors`)
|
||||
towards other contracts.
|
||||
towards other contracts.
|
||||
|
||||
.. _structure-function-modifiers:
|
||||
|
||||
@ -57,15 +57,15 @@ Function modifiers can be used to amend the semantics of functions in a declarat
|
||||
(see :ref:`modifiers` in contracts section).
|
||||
|
||||
::
|
||||
|
||||
|
||||
contract Purchase {
|
||||
address public seller;
|
||||
|
||||
|
||||
modifier onlySeller() { // Modifier
|
||||
if (msg.sender != seller) throw;
|
||||
_
|
||||
}
|
||||
|
||||
|
||||
function abort() onlySeller { // Modifier usage
|
||||
// ...
|
||||
}
|
||||
@ -82,14 +82,14 @@ Events are convenience interfaces with the EVM logging facilities.
|
||||
|
||||
contract SimpleAuction {
|
||||
event HighestBidIncreased(address bidder, uint amount); // Event
|
||||
|
||||
|
||||
function bid() {
|
||||
// ...
|
||||
HighestBidIncreased(msg.sender, msg.value); // Triggering event
|
||||
}
|
||||
}
|
||||
|
||||
See :ref:`events` in contracts section for information on how events are declared
|
||||
See :ref:`events` in contracts section for information on how events are declared
|
||||
and can be used from within a dapp.
|
||||
|
||||
.. _structure-structs-types:
|
||||
@ -97,7 +97,7 @@ and can be used from within a dapp.
|
||||
Structs Types
|
||||
=============
|
||||
|
||||
Structs are custom defined types that can group several variables (see
|
||||
Structs are custom defined types that can group several variables (see
|
||||
:ref:`structs` in types section).
|
||||
|
||||
::
|
||||
@ -116,11 +116,11 @@ Structs are custom defined types that can group several variables (see
|
||||
Enum Types
|
||||
==========
|
||||
|
||||
Enums can be used to create custom types with a finite set of values (see
|
||||
Enums can be used to create custom types with a finite set of values (see
|
||||
:ref:`enums` in types section).
|
||||
|
||||
::
|
||||
|
||||
|
||||
contract Purchase {
|
||||
enum State { Created, Locked, Inactive } // Enum
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ Booleans
|
||||
|
||||
`bool`: The possible values are constants `true` and `false`.
|
||||
|
||||
Operators:
|
||||
Operators:
|
||||
|
||||
* `!` (logical negation)
|
||||
* `&&` (logical conjunction, "and")
|
||||
@ -45,10 +45,10 @@ Integers
|
||||
|
||||
`int` / `uint`: Signed and unsigned integers of various sizes. Keywords `uint8` to `uint256` in steps of `8` (unsigned of 8 up to 256 bits) and `int8` to `int256`. `uint` and `int` are aliases for `uint256` and `int256`, respectively.
|
||||
|
||||
Operators:
|
||||
Operators:
|
||||
|
||||
* Comparisons: `<=`, `<`, `==`, `!=`, `>=`, `>` (evaluate to `bool`)
|
||||
* Bit operators: `&`, `|`, `^` (bitwise exclusive or), `~` (bitwise negation)
|
||||
* Comparisons: `<=`, `<`, `==`, `!=`, `>=`, `>` (evaluate to `bool`)
|
||||
* Bit operators: `&`, `|`, `^` (bitwise exclusive or), `~` (bitwise negation)
|
||||
* Arithmetic operators: `+`, `-`, unary `-`, unary `+`, `*`, `/`, `%` (remainder), `**` (exponentiation)
|
||||
|
||||
Division always truncates (it just maps to the DIV opcode of the EVM), but it does not truncate if both
|
||||
@ -61,7 +61,7 @@ Address
|
||||
|
||||
`address`: Holds a 20 byte value (size of an Ethereum address). Address types also have members and serve as base for all contracts.
|
||||
|
||||
Operators:
|
||||
Operators:
|
||||
|
||||
* `<=`, `<`, `==`, `!=`, `>=` and `>`
|
||||
|
||||
@ -109,12 +109,12 @@ All three functions `call`, `delegatecall` and `callcode` are very low-level fun
|
||||
Fixed-size byte arrays
|
||||
----------------------
|
||||
|
||||
`bytes1`, `bytes2`, `bytes3`, ..., `bytes32`. `byte` is an alias for `bytes1`.
|
||||
`bytes1`, `bytes2`, `bytes3`, ..., `bytes32`. `byte` is an alias for `bytes1`.
|
||||
|
||||
Operators:
|
||||
Operators:
|
||||
|
||||
* Comparisons: `<=`, `<`, `==`, `!=`, `>=`, `>` (evaluate to `bool`)
|
||||
* Bit operators: `&`, `|`, `^` (bitwise exclusive or), `~` (bitwise negation)
|
||||
* Comparisons: `<=`, `<`, `==`, `!=`, `>=`, `>` (evaluate to `bool`)
|
||||
* Bit operators: `&`, `|`, `^` (bitwise exclusive or), `~` (bitwise negation)
|
||||
* Index access: If `x` is of type `bytesI`, then `x[k]` for `0 <= k < I` returns the `k` th byte (read-only).
|
||||
|
||||
Members:
|
||||
@ -125,7 +125,7 @@ Dynamically-sized byte array
|
||||
----------------------------
|
||||
|
||||
`bytes`:
|
||||
Dynamically-sized byte array, see :ref:`arrays`. Not a value-type!
|
||||
Dynamically-sized byte array, see :ref:`arrays`. Not a value-type!
|
||||
`string`:
|
||||
Dynamically-sized UTF8-encoded string, see :ref:`arrays`. Not a value-type!
|
||||
|
||||
@ -140,7 +140,7 @@ number of bytes, always use one of `bytes1` to `bytes32` because they are much c
|
||||
Integer Literals
|
||||
-----------------
|
||||
|
||||
Integer Literals are arbitrary precision integers until they are used together with a non-literal. In `var x = 1 - 2;`, for example, the value of `1 - 2` is `-1`, which is assigned to `x` and thus `x` receives the type `int8` -- the smallest type that contains `-1`, although the natural types of `1` and `2` are actually `uint8`.
|
||||
Integer Literals are arbitrary precision integers until they are used together with a non-literal. In `var x = 1 - 2;`, for example, the value of `1 - 2` is `-1`, which is assigned to `x` and thus `x` receives the type `int8` -- the smallest type that contains `-1`, although the natural types of `1` and `2` are actually `uint8`.
|
||||
|
||||
It is even possible to temporarily exceed the maximum of 256 bits as long as only integer literals are used for the computation: `var x = (0xffffffffffffffffffff * 0xffffffffffffffffffff) * 0;` Here, `x` will have the value `0` and thus the type `uint8`.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user