Smart Contract (SC)
(Redirected from Smart Contract)
- Phrase coined by computer scientist Nick Szabo in 1994
- Smart Contracts are, in a simplified manner, contracts that execute themselves. In its most basic form, a smart contract may consist of a transaction that is triggered by an event, for example another transaction or a certain block height being reached.
- The purpose of these contracts is to eliminate the need for trusted third parties completely. Before the inception of smart contracts, the conditional release of funds can only be expected to work with a trusted party holding the funds to be released once the condition is met. With smart contracts, the transaction is programmed to happen once the condition is met, with no human action required. This eliminates the need for trust and the fees associated with hiring a third party.
- From this thread on how to read a SC (10-1-2022):
"It’s a program that executes code on the blockchain when conditions are met. Parties sign the contract digitally, giving it permission to execute. This could be anything from sending money to a friend, to fractionalizing an NFT."
Types of Smart Contracts
- There are two types of smart contracts: Deterministic and non-deterministic. These are defined by the availability of the conditions required to trigger actions in the smart contract.
- A deterministic smart contract gets all of its information from the blockchain on which it operates. This information can be a certain transaction, a certain block-height, the execution of another contract and so on, as long as the information can be found on the blockchain. (Examples: Provably fair lotteries, multisig transactions)
- The other kind, nondeterministic smart contracts, require information that is exterior to the blockchain. This can be anything from the result of a soccer match to a weather report, to the results of an election. Anything you can think of. However, these types of contracts do require the user to trust an Oracle. The Oracle is the “missing link” between the blockchain and the real world. Through an oracle, the smart contract can be fed information about an exterior event and be triggered by it. This, of course, requires a user to trust the Oracle that is used. However, it is also possible to use a decentralized method in which a group of token holders can vote on a certain event outcome and thus trigger a smart contract. This system is applied in the Augur prediction market. (Examples: Sports betting, prediction markets)
- Smart contracts can, not only trigger the release of funds, but they can also trigger other complex actions. A system of smart contracts can be arranged to build decentralized applications, something that is already taking place on the Ethereum network with projects like: Augur, FirstBlood, and others.
Interacting with Smart Contracts
- From this article (12-12-2019):
"Smart contracts can be interacted with in two different ways: through calls and through transactions. A call is a local invocation of a contract function, and it does not broadcast anything to the blockchain. Because of this, calls are read-only, can not make any changes to the contract state and do not incur any fees.
On the other hand, transactions are write operations that do get broadcasted to the network, are included on the blockchain and do incur a miner fee. To take ERC20 tokens as an example, token balances are retrieved with a call, while tokens are transferred with a transaction.
While smart contracts can interact with each other, every transaction on-chain needs to be originated from an external account. So contract-to-contract interactions still have to be triggered through an initial transaction by a user. After this initial trigger, contract-to-contract interactions are similar to direct interactions.
In other words, it's possible for contracts to call read-only functions of other smart contract or trigger write operations. Since only external accounts can trigger transactions, write operations between contracts are referred to as internal transactions or message calls to make the distinction with user-initiated transactions."
Bitcoin, Bitcoin Cash and Ethereum
- From this article (12-12-2019) which explains the differences between the platforms and their capabilities when it comes to smart contracts:
"Ethereum was the first platform with Turing-complete smart contracts, it was already possible to create rudimentary contracts on Bitcoin using a language called Bitcoin Script. Bitcoin Cash has recently been improving its smart contract capabilities."