From 49f5bc7ce946bb2100406b0fb20d3e73d3da4292 Mon Sep 17 00:00:00 2001 From: Denton Liu Date: Tue, 24 May 2016 13:57:36 -0400 Subject: Changed inline code syntax Changed from :code:`` to ```` --- docs/contracts.rst | 120 ++++++++++++++++++++++++++--------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) (limited to 'docs/contracts.rst') diff --git a/docs/contracts.rst b/docs/contracts.rst index c148d55c..c94f8d99 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -20,7 +20,7 @@ Contracts can be created "from outside" or from Solidity contracts. When a contract is created, its constructor (a function with the same name as the contract) is executed once. -From :code:`web3.js`, i.e. the JavaScript +From ``web3.js``, i.e. the JavaScript API, this is done as follows:: // The json abi array generated by the compiler @@ -53,7 +53,7 @@ API, this is done as follows:: Internally, constructor arguments are passed after the code of the contract itself, but you do not have to care about this -if you use :code:`web3.js`. +if you use ``web3.js``. If a contract wants to create another contract, the source code (and the binary) of the created contract has to be known to the creator. @@ -143,38 +143,38 @@ a "message call") and external ones that do), there are four types of visibilities for functions and state variables. -Functions can be specified as being :code:`external`, -:code:`public`, :code:`internal` or :code:`private`, where the default is -:code:`public`. For state variables, :code:`external` is not possible -and the default is :code:`internal`. +Functions can be specified as being ``external``, +``public``, ``internal`` or ``private``, where the default is +``public``. For state variables, ``external`` is not possible +and the default is ``internal``. -:code:`external`: +``external``: External functions are part of the contract interface, which means they can be called from other contracts and - via transactions. An external function :code:`f` cannot be called - internally (i.e. :code:`f()` does not work, but :code:`this.f()` works). + via transactions. An external function ``f`` cannot be called + internally (i.e. ``f()`` does not work, but ``this.f()`` works). External functions are sometimes more efficient when they receive large arrays of data. -:code:`public`: +``public``: Public functions are part of the contract interface and can be either called internally or via messages. For public state variables, an automatic accessor function (see below) is generated. -:code:`internal`: +``internal``: Those functions and state variables can only be accessed internally (i.e. from within the current contract - or contracts deriving from it), without using :code:`this`. + or contracts deriving from it), without using ``this``. -:code:`private`: +``private``: Private functions and state variables are only visible for the contract they are defined in and not in derived contracts. .. note:: Everything that is inside a contract is visible to - all external observers. Making something :code:`private` + all external observers. Making something ``private`` only prevents other contract from accessing and modifying the information, but it will still be visible to the whole world outside of the blockchain. @@ -191,9 +191,9 @@ return parameter list for functions. uint public data; } -Other contracts can call :code:`c.data()` to retrieve the value of data in state -storage, but are not able to call :code:`f`. Contracts derived from :code:`c` can call -:code:`setData` to alter the value of :code:`data` (but only in their own state). +Other contracts can call ``c.data()`` to retrieve the value of data in state +storage, but are not able to call ``f``. Contracts derived from ``c`` can call +``setData`` to alter the value of ``data`` (but only in their own state). .. index:: ! accessor;function, ! function;accessor @@ -202,15 +202,15 @@ Accessor Functions The compiler automatically creates accessor functions for all public state variables. The contract given below will -have a function called :code:`data` that does not take any +have a function called ``data`` that does not take any arguments and returns a uint, the value of the state -variable :code:`data`. The initialization of state variables can +variable ``data``. The initialization of state variables can be done at declaration. The accessor functions have external visibility. If the -symbol is accessed internally (i.e. without :code:`this.`), +symbol is accessed internally (i.e. without ``this.``), it is a state variable and if it is accessed externally -(i.e. with :code:`this.`), it is a function. +(i.e. with ``this.``), it is a function. :: @@ -414,15 +414,15 @@ ultimately, also the block headers have to be supplied because the contract can only see the last 256 block hashes). Up to three parameters can -receive the attribute :code:`indexed` which will cause the respective arguments +receive the attribute ``indexed`` which will cause the respective arguments to be searched for: It is possible to filter for specific values of indexed arguments in the user interface. -If arrays (including :code:`string` and :code:`bytes`) are used as indexed arguments, the +If arrays (including ``string`` and ``bytes``) are used as indexed arguments, the sha3-hash of it is stored as topic instead. The hash of the signature of the event is one of the topics except if you -declared the event with :code:`anonymous` specifier. This means that it is +declared the event with ``anonymous`` specifier. This means that it is not possible to filter for specific anonymous events by name. All non-indexed arguments will be stored in the data part of the log. @@ -475,8 +475,8 @@ Low-Level Interface to Logs =========================== It is also possible to access the low-level interface to the logging -mechanism via the functions :code:`log0`, :code:`log1`, :code:`log2`, :code:`log3` and :code:`log4`. -:code:`logi` takes :code:`i + 1` parameter of type :code:`bytes32`, where the first +mechanism via the functions ``log0``, ``log1``, ``log2``, ``log3`` and ``log4``. +``logi`` takes ``i + 1`` parameter of type ``bytes32``, where the first argument will be used for the data part of the log and the others as topics. The event call above can be performed in the same way as @@ -490,7 +490,7 @@ as topics. The event call above can be performed in the same way as ); where the long hexadecimal number is equal to -:code:`sha3("Deposit(address,hash256,uint256)")`, the signature of the event. +``sha3("Deposit(address,hash256,uint256)")``, the signature of the event. Additional Resources for Understanding Events ============================================== @@ -591,7 +591,7 @@ Details are given in the following example. uint info; } -Note that above, we call :code:`mortal.kill()` to "forward" the +Note that above, we call ``mortal.kill()`` to "forward" the destruction request. The way this is done is problematic, as seen in the following example:: @@ -615,10 +615,10 @@ seen in the following example:: contract Final is Base1, Base2 { } -A call to :code:`Final.kill()` will call :code:`Base2.kill` as the most +A call to ``Final.kill()`` will call ``Base2.kill`` as the most derived override, but this function will bypass -:code:`Base1.kill`, basically because it does not even know about -:code:`Base1`. The way around this is to use :code:`super`:: +``Base1.kill``, basically because it does not even know about +``Base1``. The way around this is to use ``super``:: contract mortal is owned { function kill() { @@ -640,10 +640,10 @@ derived override, but this function will bypass contract Final is Base2, Base1 { } -If :code:`Base1` calls a function of :code:`super`, it does not simply +If ``Base1`` calls a function of ``super``, it does not simply call this function on one of its base contracts, it rather calls this function on the next base contract in the final -inheritance graph, so it will call :code:`Base2.kill()` (note that +inheritance graph, so it will call ``Base2.kill()`` (note that the final inheritance sequence is -- starting with the most derived contract: Final, Base1, Base2, mortal, owned). The actual function that is called when using super is @@ -670,9 +670,9 @@ the base constructors. This can be done at two places:: } } -Either directly in the inheritance list (:code:`is Base(7)`) or in +Either directly in the inheritance list (``is Base(7)``) or in the way a modifier would be invoked as part of the header of -the derived constructor (:code:`Base(_y * _y)`). The first way to +the derived constructor (``Base(_y * _y)``). The first way to do it is more convenient if the constructor argument is a constant and defines the behaviour of the contract or describes it. The second way has to be used if the @@ -691,7 +691,7 @@ Solidity follows the path of Python and uses "`C3 Linearization