Skip to content

Commit

Permalink
Merge pull request #12751 from andreb0x/patch-2
Browse files Browse the repository at this point in the history
updates to gas section
  • Loading branch information
nishant-sachdeva authored Apr 7, 2022
2 parents 52f5ffd + 6041612 commit 803585d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions docs/introduction-to-smart-contracts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -396,14 +396,15 @@ returns that code when executed.
Gas
===

Upon creation, each transaction is charged with a certain amount of **gas**,
whose purpose is to limit the amount of work that is needed to execute
the transaction and to pay for this execution at the same time. While the EVM executes the
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, 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 the execution, it is refunded to the creator in the same way.
If some gas is left after execution, it is refunded to the transaction originator.

If the gas is used up at any point (i.e. it would be negative),
an out-of-gas exception is triggered, which reverts all modifications
Expand All @@ -415,8 +416,7 @@ Storage, Memory and the Stack
=============================

The Ethereum Virtual Machine has three areas where it can store data-
storage, memory and the stack, which are explained in the following
paragraphs.
storage, memory and the stack.

Each account has a data area called **storage**, which is persistent between function calls
and transactions.
Expand Down Expand Up @@ -505,7 +505,9 @@ 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
contract and ``msg.sender`` and ``msg.value`` do not change their values.
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.

This means that a contract can dynamically load code from a different
address at runtime. Storage, current address and balance still
Expand Down

0 comments on commit 803585d

Please sign in to comment.