Difference between revisions of "Smart contract"

From DefiLlama
Jump to navigation Jump to search
(wrote smart contract)
 
(first edit)
 
Line 1: Line 1:
A smart contract is a self-executing contract with the terms of the agreement between buyer and seller being directly written into lines of code inside it. The code and the agreements contained therein exist across a distributed, decentralized blockchain network. Smart contracts need no third parties unlike centralized finance.
A smart contract is a self-executing contract with the terms of the agreement between buyer and seller being directly written into lines of code inside it. The code and the agreements contained therein exist across a distributed, decentralized [[blockchain]] network. Smart contracts need no third parties unlike centralized finance.
 
== History ==
Nick Szabo is the creator of smart contract technology. He did this in 1996 -1997.
 
He offered to use computer algorithms with user interfaces to close deals in the area of the electronic commerce. According to the author’s idea, the description of the contract terms had to be made with the use of mathematical tools and programming languages. The idea of Nick Szabo about smart contracts was put into practice for the first time by Vitalik Buterin in his [[Ethereum]] Project (2013).
 
== Smart contracts in blockchain ==
The realization of Szabo’s idea became possible with the appearance of the blockchain technology, which ensures the reliability and protection of a smart contract due to its characteristics:
 
* Decentralized system type: None of the contract parties may change the text of the document, since a copy of the agreement is kept in the register, distributed between numerous network nodes.
 
* Open databases: The contract terms are available for all blockchain participants – the audit of the contract execution becomes easier.
 
* Formalization of the contract terms: The check and execution of the contract terms is made with a program code (if-this-then-that (IFTTT)), which is why the possibility of a wrong contract execution is excluded.
 
* Atomic operations: A contact will be either implemented successfully or not implemented at all.
 
* Turing completeness: The blockchain presented in Ethereum, has a built-in Turing-full programming language, thanks to which the users will be able to create any contracts by themselves.
 
== Security and sensibilities ==
Smart contracts in Ethereum are vulnerable to hacker attacks for a number of reasons.
 
1. Errors in the use of Solidity (the Ethereum programming language)
 
* Semantics: smart contracts are written in Solidity, which is similar to Java. However, the bytecode of the [[EVM]] does not support work with functions, so the contracts are compiled before being sent to the blockchain. One typing error in the contract code may lead to the implementation of the fallback function.
 
* Incorrect order of exceptions: For the implementation of a smart contract, an interruption of the work of its method – an exception may be needed. If an exception appears during the running of the call command, then the execution of contracts will continue until the gas is over.
 
* Reenterability: The same program instructions may be entered for several times, for example, through the fallback function, which will lead to a cycle in the calling of the call method and expending the whole gas
 
2. Errors in the work of the Ethereum virtual machine
 
* Invariability of contracts: A contract published on the blockchain cannot be changed. If a contract contains a bug, it’s impossible to correct, the contract execution only can be stopped.
 
* Ether losses during the transfer: To send ether, you need to give the address of the receiving party, which presents a sequence of 160 bits. If the given address is not bound to a user or a contract, the sent ether will be lost forever.
 
3. Blockchain errors
 
* State of a contract: A part of a smart contract that came into a short sub circuit won’t be executed. Accordingly, the contract status won’t be determined uniquely temporarily. One of the contract parties may consider that the contract has been executed although it didn’t happen.
 
* Temporary restrictions: To determine the state of a contract, some time is needed (see the previous paragraph), which makes it vulnerable to attacks.
 
== Sources: ==
https://en.bitcoinwiki.org/wiki/Smart_contract
__NOEDITSECTION__
[[Category:Glossary]]

Latest revision as of 04:57, 1 May 2022

A smart contract is a self-executing contract with the terms of the agreement between buyer and seller being directly written into lines of code inside it. The code and the agreements contained therein exist across a distributed, decentralized blockchain network. Smart contracts need no third parties unlike centralized finance.

History

Nick Szabo is the creator of smart contract technology. He did this in 1996 -1997.

He offered to use computer algorithms with user interfaces to close deals in the area of the electronic commerce. According to the author’s idea, the description of the contract terms had to be made with the use of mathematical tools and programming languages. The idea of Nick Szabo about smart contracts was put into practice for the first time by Vitalik Buterin in his Ethereum Project (2013).

Smart contracts in blockchain

The realization of Szabo’s idea became possible with the appearance of the blockchain technology, which ensures the reliability and protection of a smart contract due to its characteristics:

  • Decentralized system type: None of the contract parties may change the text of the document, since a copy of the agreement is kept in the register, distributed between numerous network nodes.
  • Open databases: The contract terms are available for all blockchain participants – the audit of the contract execution becomes easier.
  • Formalization of the contract terms: The check and execution of the contract terms is made with a program code (if-this-then-that (IFTTT)), which is why the possibility of a wrong contract execution is excluded.
  • Atomic operations: A contact will be either implemented successfully or not implemented at all.
  • Turing completeness: The blockchain presented in Ethereum, has a built-in Turing-full programming language, thanks to which the users will be able to create any contracts by themselves.

Security and sensibilities

Smart contracts in Ethereum are vulnerable to hacker attacks for a number of reasons.

1. Errors in the use of Solidity (the Ethereum programming language)

  • Semantics: smart contracts are written in Solidity, which is similar to Java. However, the bytecode of the EVM does not support work with functions, so the contracts are compiled before being sent to the blockchain. One typing error in the contract code may lead to the implementation of the fallback function.
  • Incorrect order of exceptions: For the implementation of a smart contract, an interruption of the work of its method – an exception may be needed. If an exception appears during the running of the call command, then the execution of contracts will continue until the gas is over.
  • Reenterability: The same program instructions may be entered for several times, for example, through the fallback function, which will lead to a cycle in the calling of the call method and expending the whole gas

2. Errors in the work of the Ethereum virtual machine

  • Invariability of contracts: A contract published on the blockchain cannot be changed. If a contract contains a bug, it’s impossible to correct, the contract execution only can be stopped.
  • Ether losses during the transfer: To send ether, you need to give the address of the receiving party, which presents a sequence of 160 bits. If the given address is not bound to a user or a contract, the sent ether will be lost forever.

3. Blockchain errors

  • State of a contract: A part of a smart contract that came into a short sub circuit won’t be executed. Accordingly, the contract status won’t be determined uniquely temporarily. One of the contract parties may consider that the contract has been executed although it didn’t happen.
  • Temporary restrictions: To determine the state of a contract, some time is needed (see the previous paragraph), which makes it vulnerable to attacks.

Sources:

https://en.bitcoinwiki.org/wiki/Smart_contract