The a contract account, every time the contract account

The main idea behind the Ethereum is to provide a Turing-complete programming language for development of smart contracts which can be deployed and run on Ethereum network. Ethereum provides the abstract layer which is build on a blockchain, and can run smart contractscite{buterin2013ethereum}. On the Ethereum network contract is represented by a piece of code, that can be invoked by sending a transaction or message to it.

Once the contract is deployed to a blockchain, every node has access to it, and can execute it’s code in the local Ethereum Virtual Machine. When smart contract receives message or transaction, code is executed, running all the logic that is programmed in it. The piece of code is run by every node in the network, because each node have to confirm the transaction, just like in the Bitcoin network.

In Ethereum contract have local key-value storage, which maintains persistent stage, and its own account which maintains the amount of ether. Ether is a name of internal Ethereum network token, just like a Bitcoin in the Bitcoin network. Ether is used to pay the transaction fees, and to pay for the contract execution.

Every operation coded inside the contract have a cost measured in Ether, contract storage also have a certain cost. It’s done as a preventive measure to avoid attack, when contract is invoked, one must also provide a fee, to pay for the execution of the contract, if it’s not enough, then execution is stopped, result is reverted, but fee is still paid, this system prevent misuse of the contract, if contract have an infinite loop coded in, it will not be able to halt the network, instead it will run out of gas. “Ether” is the main internal crypto-fuel of Ethereum, and is used to pay transaction fees.

In general, there are two types of accounts: externally owned accounts, controlled by private keys, and contract accounts, controlled by their contract code. An externally owned account has no code, and one can send messages from an externally owned account by creating and signing a transaction; in a contract account, every time the contract account receives a message its code activates, allowing it to read and write to internal storage and send other messages or create contracts in turn. Note that “contracts” in Ethereum should not be seen as something that should be “fulfilled” or “complied with”; rather, they are more like “autonomous agents” that live inside of the Ethereum execution environment, always executing a specific piece of code when “poked” by a message or transaction, and having direct control over their own ether balance and their own key/value store to keep track of persistent variables.