# Smart Contract
A smart contract is a self-executing program based on if-then logic<ref>https://www.techtarget.com/searchcio/feature/Examples-of-smart-contracts-on-blockchain</ref>. Since smart contracts have been running on blockchains, app. from 2017 onwards, they gained huge popularity over time and made decentralized Finance possible.
## Overview
A smart contract is in principle, like any other contract, a **documented agreement between parties** but it has three features which make it "smart":
1) The contract conditions are layed down in programming [[code]].
2) It is safety secured on a [blockchain](wiki/blockchain) and thus public, decentrally stored and immutable.
3) If certain conditions of the contract are met, the contract can trigger automatically certain (financial) [[transactions]].
The term "smart contract" was created by [[Nick Szabo]] already in the 1990ies, several years before the appearance of the first blockchain<ref>https://pontem.network/posts/the-history-of-smart-contracts</ref> . He defined them as digital protocols that enable information transfer using mathematical algorithms to execute transactions over computer networks instead per law, secured by cryptography.
Experts estimate that the use of smart contracts on blockchains will growing significantly, especially in insurance, banking, government, and other sectors with similar needs, to run their operations more efficiently and use the advantages of smart contracts, accuracy, transparency and cost saving<ref>https://www.oracle.com/blockchain/what-is-blockchain/smart-contracts-blockchain/</ref>.
Some blockchains feature per default smart contracts, others not (at least not on their [[layer 1]]). [[Bitcoin]] and [[Hive]] are blockchains without smart contracts. [[Ethereum]] was the first blockchain offering this capability, also e.g. [[Cardano]] and [[Solana]] allow smart contracts.
## Some use cases of smart contracts
### DeFi
DeFi (Decentralized Finance) stands for all kind of decentralized financial services, made possible by smart contracts. E.g. [[Uniswap]] is a popular [DApp](/wiki/Decentralized-Application) that allows peer-to-peer transfer and exchange of cryptocurrencies and tokens and operates on the [[Ethereum]] blockchain. It is also an example of a [DEX](/wiki/Decentralized-exchange) (decentralized exchange).
### ERC-20 tokens
These tokens (created as L2-tokens on the [[Ethereum]] blockchains) are smart contracts as well. ERC-20 tokens are fungible which means one token of the same type is completely identical to another one. This separates them from non-fungible tokens ([NFTs](/wiki/NFT)) which have a unique identity.
They were created 2017 after a proposal by developer Fabian Vogelsteller (comment no. 20 on a github page as an Ethereum Request for Comment, hence the name ERC-20)<ref>https://www.investopedia.com/news/what-erc20-and-what-does-it-mean-ethereum/</ref>.
### Smart contracts on Hive
The second layer platform [Hive-Engine](/wiki/Hive-Engine) allows smart contracts for example to create tokens for games like [SPS](/wiki/Splintershards) or for investment like [[SPI]], but also to create and manage [DeFi](/wiki/Smart-Contract/###DeFi) applications like [liquidity pools](/wiki/liquidity-pool).
Website: https://hive-engine.com/
Currently still in development is the smart contract platform VSC which will allow fully customizable smart contracts in any language and decentralized Bitcoin wrapping. A testnet went recently online <ref>https://hive.blog/vsc/@vsc.network/next-phase-of-vsc-hive-smart-contracts-and-v4v-joint-dhf-proposal</ref>.
## Downsides of Smart Contracts
These include (currently) minimal acceptance by governments and thus limited protection and insurance against bad actors. Smart contracts may also contain logic mistakes (or malignant code) which could lead to exploitation by hackers who know the weaknesses of certain smart contracts. This risk can be mitigated by independent code audits.
## Overview
A smart contract is in principle, like any other contract, a **documented agreement between parties** but it has three features which make it "smart":
1) The contract conditions are layed down in programming [[code]].
2) It is safety secured on a [blockchain](wiki/blockchain) and thus public, decentrally stored and immutable.
3) If certain conditions of the contract are met, the contract can trigger automatically certain (financial) [[transactions]].
The term "smart contract" was created by [[Nick Szabo]] already in the 1990ies, several years before the appearance of the first blockchain<ref>https://pontem.network/posts/the-history-of-smart-contracts</ref> . He defined them as digital protocols that enable information transfer using mathematical algorithms to execute transactions over computer networks instead per law, secured by cryptography.
Experts estimate that the use of smart contracts on blockchains will growing significantly, especially in insurance, banking, government, and other sectors with similar needs, to run their operations more efficiently and use the advantages of smart contracts, accuracy, transparency and cost saving<ref>https://www.oracle.com/blockchain/what-is-blockchain/smart-contracts-blockchain/</ref>.
Some blockchains feature per default smart contracts, others not (at least not on their [[layer 1]]). [[Bitcoin]] and [[Hive]] are blockchains without smart contracts. [[Ethereum]] was the first blockchain offering this capability, also e.g. [[Cardano]] and [[Solana]] allow smart contracts.
## Some use cases of smart contracts
### DeFi
DeFi (Decentralized Finance) stands for all kind of decentralized financial services, made possible by smart contracts. E.g. [[Uniswap]] is a popular [DApp](/wiki/Decentralized-Application) that allows peer-to-peer transfer and exchange of cryptocurrencies and tokens and operates on the [[Ethereum]] blockchain. It is also an example of a [DEX](/wiki/Decentralized-exchange) (decentralized exchange).
### ERC-20 tokens
These tokens (created as L2-tokens on the [[Ethereum]] blockchains) are smart contracts as well. ERC-20 tokens are fungible which means one token of the same type is completely identical to another one. This separates them from non-fungible tokens ([NFTs](/wiki/NFT)) which have a unique identity.
They were created 2017 after a proposal by developer Fabian Vogelsteller (comment no. 20 on a github page as an Ethereum Request for Comment, hence the name ERC-20)<ref>https://www.investopedia.com/news/what-erc20-and-what-does-it-mean-ethereum/</ref>.
### Smart contracts on Hive
The second layer platform [Hive-Engine](/wiki/Hive-Engine) allows smart contracts for example to create tokens for games like [SPS](/wiki/Splintershards) or for investment like [[SPI]], but also to create and manage [DeFi](/wiki/Smart-Contract/###DeFi) applications like [liquidity pools](/wiki/liquidity-pool).
Website: https://hive-engine.com/
Currently still in development is the smart contract platform VSC which will allow fully customizable smart contracts in any language and decentralized Bitcoin wrapping. A testnet went recently online <ref>https://hive.blog/vsc/@vsc.network/next-phase-of-vsc-hive-smart-contracts-and-v4v-joint-dhf-proposal</ref>.
## Downsides of Smart Contracts
These include (currently) minimal acceptance by governments and thus limited protection and insurance against bad actors. Smart contracts may also contain logic mistakes (or malignant code) which could lead to exploitation by hackers who know the weaknesses of certain smart contracts. This risk can be mitigated by independent code audits.