mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Update introduction-to-smart-contracts.rst
modifying "write" to "transactions"
This commit is contained in:
parent
39f3175a37
commit
60416120af
@ -396,13 +396,13 @@ returns that code when executed.
|
||||
Gas
|
||||
===
|
||||
|
||||
Upon creation, each transaction is charged with a certain amount of **gas**.
|
||||
Imposing a cost on operations that write to the blockchain serves to secure the network:
|
||||
Upon creation, each transaction is charged with a certain amount of **gas**.
|
||||
Imposing a cost on transactions serves to secure the network:
|
||||
it deincentivizes bad actors from spamming, and pays validators (i.e. miners and stakers)
|
||||
for the work that is required to validate new blocks. While the EVM executes the
|
||||
transaction, the gas is gradually depleted according to specific rules.
|
||||
|
||||
The **gas price** is a value set by the creator of the transaction (see `msg.sender), who
|
||||
The **gas price** is a value set by the originator of the transaction, i.e. `tx.origin`, who
|
||||
has to pay ``gas_price * gas`` up front from the sending account.
|
||||
If some gas is left after execution, it is refunded to the transaction originator.
|
||||
|
||||
@ -505,25 +505,14 @@ Delegatecall / Callcode and Libraries
|
||||
There exists a special variant of a message call, named **delegatecall**
|
||||
which is identical to a message call apart from the fact that
|
||||
the code at the target address is executed in the context of the calling
|
||||
<<<<<<< HEAD
|
||||
contract. In practice this means ``msg.sender`` and ``msg.value`` retain
|
||||
the values that were passed to the delegator, while executing code that
|
||||
lives in the delegated contract.
|
||||
=======
|
||||
contract. In practice this means ``msg.sender`` and ``msg.value`` retain
|
||||
the values that were passed to the delegator, while executing code that
|
||||
lives in the delegated contract.
|
||||
>>>>>>> updates to delegatecall
|
||||
|
||||
This means that a contract can dynamically load code from a different
|
||||
address at runtime. Storage, current address and balance still
|
||||
refer to the calling contract, only the code is taken from the called address.
|
||||
|
||||
For example, say Alice calls a method in contract A to modify
|
||||
state variable `A.var` according to method ``A.foo()``.
|
||||
If contract A then delegates call to contract B, the logic of `B.foo()`
|
||||
will be executed, but modifications will be made to state variable `A.var`.
|
||||
|
||||
This makes it possible to implement the "library" feature in Solidity:
|
||||
Reusable library code that can be applied to a contract's storage, e.g. in
|
||||
order to implement a complex data structure.
|
||||
|
Loading…
Reference in New Issue
Block a user