Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 07smart-contracts-solidity.asciidoc : Fixed some broken links #1191

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions 07smart-contracts-solidity.asciidoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[[smart_contracts_chapter]]
== Smart Contracts and Solidity

((("smart contracts", id="ix_07smart-contracts-solidity-asciidoc0", range="startofrange")))As we discussed in <<intro_chapter>>, there are two different types of accounts in Ethereum: ((("EOA (Externally Owned Account)","contract accounts compared to")))externally owned accounts (EOAs) and contract accounts. EOAs are controlled by users, often via software such as a wallet application that is external to the Ethereum platform. ((("contract accounts","EOAs compared to")))((("smart contracts","EOAs compared to")))In contrast, contract accounts are controlled by program code (also commonly referred to as &#x201c;smart contracts&#x201d;) that is executed by the Ethereum Virtual Machine. In short, EOAs are simple accounts without any associated code or data storage, whereas contract accounts have both associated code and data storage. EOAs are controlled by transactions created and cryptographically signed with a private key in the "real world" external to and independent of the protocol, whereas contract accounts do not have private keys and so "control themselves" in the predetermined way prescribed by their smart contract code. Both types of accounts are identified by an Ethereum address. In this chapter, we will discuss contract accounts and the program code that controls them.
((("smart contracts", id="ix_07smart-contracts-solidity-asciidoc0", range="startofrange")))As we discussed in https://github.com/ethereumbook/ethereumbook/blob/develop/02intro.asciidoc#externally-owned-accounts-eoas-and-contracts[intro_chapter], there are two different types of accounts in Ethereum: ((("EOA (Externally Owned Account)","contract accounts compared to")))externally owned accounts (EOAs) and contract accounts. EOAs are controlled by users, often via software such as a wallet application that is external to the Ethereum platform. ((("contract accounts","EOAs compared to")))((("smart contracts","EOAs compared to")))In contrast, contract accounts are controlled by program code (also commonly referred to as &#x201c;smart contracts&#x201d;) that is executed by the Ethereum Virtual Machine. In short, EOAs are simple accounts without any associated code or data storage, whereas contract accounts have both associated code and data storage. EOAs are controlled by transactions created and cryptographically signed with a private key in the "real world" external to and independent of the protocol, whereas contract accounts do not have private keys and so "control themselves" in the predetermined way prescribed by their smart contract code. Both types of accounts are identified by an Ethereum address. In this chapter, we will discuss contract accounts and the program code that controls them.

[[smart_contracts_definition]]
=== What Is a Smart Contract?
Expand All @@ -28,7 +28,7 @@ The EVM runs as a local instance on every Ethereum node, but because all instanc
[[smart_contract_lifecycle]]
=== Life Cycle of a Smart Contract

((("smart contracts","life cycle of")))Smart contracts are typically written in a high-level language, such as Solidity. But in order to run, they must be compiled to the low-level bytecode that runs in the EVM. Once compiled, they are deployed on the Ethereum platform using a special _contract creation_ transaction, which is identified as such by being sent to the special contract creation address, namely +0x0+ (see <<contract_reg>>). Each contract is identified by an Ethereum address, which is derived from the contract creation transaction as a function of the originating account and nonce. The Ethereum address of a contract can be used in a transaction as the recipient, sending funds to the contract or calling one of the contract’s functions. Note that, unlike with EOAs, there are no keys associated with an account created for a new smart contract. As the contract creator, you don't get any special privileges at the protocol level (although you can explicitly code them into the smart contract). You certainly don't receive the private key for the contract account, which in fact does not exist&#x2014;we can say that smart contract accounts own themselves.
((("smart contracts","life cycle of")))Smart contracts are typically written in a high-level language, such as Solidity. But in order to run, they must be compiled to the low-level bytecode that runs in the EVM. Once compiled, they are deployed on the Ethereum platform using a special _contract creation_ transaction, which is identified as such by being sent to the special contract creation address, namely +0x0+ (see https://github.com/ethereumbook/ethereumbook/blob/develop/06transactions.asciidoc#special-transaction-contract-creation[contract_reg]). Each contract is identified by an Ethereum address, which is derived from the contract creation transaction as a function of the originating account and nonce. The Ethereum address of a contract can be used in a transaction as the recipient, sending funds to the contract or calling one of the contract’s functions. Note that, unlike with EOAs, there are no keys associated with an account created for a new smart contract. As the contract creator, you don't get any special privileges at the protocol level (although you can explicitly code them into the smart contract). You certainly don't receive the private key for the contract account, which in fact does not exist&#x2014;we can say that smart contract accounts own themselves.

((("transactions","smart contracts and")))Importantly, contracts _only run if they are called by a transaction_. All smart contracts in Ethereum are executed, ultimately, because of a transaction initiated from an EOA. A contract can call another contract that can call another contract, and so on, but the first contract in such a chain of execution will always have been called by a transaction from an EOA. Contracts never run “on their own” or “in the background.” Contracts effectively lie dormant until a transaction triggers execution, either directly or indirectly as part of a chain of contract calls. It is also worth noting that smart contracts are not executed "in parallel" in any sense&#x2014;the Ethereum world computer can be considered to be a single-threaded machine.

Expand Down