A Beginner’s Guide to Smart Contracts
- How to follow a logical path through selecting the best cloud mining services in 2021? - July 15, 2021
- Staking VS other ways of earning on cryptocurrencies – what makes most sense - June 14, 2021
- Introducing SafeHamsters - May 27, 2021
What is a ‘Smart Contract’
To put it as simply as possible, the term ‘smart contract’ can refer to any contract which is capable of executing or enforcing itself.
Smart contracts are written as programming code rather which can be run on a computer rather than in legal language on a printed document. This code can define strict rules and consequences in the same way that a traditional legal document would, stating the obligations, benefits and penalties which may be due to either party in various different circumstances. But unlike a traditional contract it can also take information as an input, process that information through the rules set out in the contract, and take any actions required of it as a result.
What’s The Point in Smart Contracts?
The main purpose of designing smart contracts is to enable people to trade and do business with strangers, usually over the internet, without the need for a large centralized authority site to act as a middleman.
This is important because the main problem with shopping online, hiring people over the internet, and generally conducting business with strangers over the internet is the issue of trust. Most business requires some element of trust. For example, if I buy something at an online shop I am trusting that they will send it to me after I make a payment, and if they do send it to me they are trusting me not to reverse my credit card payment to take both the money and take the product for free. Up until now scenarios such as this have been solved by both parties going through large well-known sites which they both trust. For example, one of the great benefits of the internet is that it enables ordinary people to easily buy and sell things between each other – but the only way we have found to solve the problem of trust is for the vast majority of this p2p trade across the whole western world to go through a single gigantic virtual-monopoly website called eBay. Not only do these giant middleman sites charge significant fees for their service, they also impose their own limits and controls on what and how people trade, therefore severely limiting our business freedom.
By solving the problem of trust without the need for middlemen smart contracts can reduce business costs, reduce consumer prices, and increase our freedom to conduct our own business in whatever way we ourselves see fit.
Types & Examples of Smart Contract
- Breach Prevention: An early and fairly simple example of a smart contract is Digital Rights Management or DRM technologies. This type of contract does not take or process inputs, but simply enforces itself by making it impossible for you to break the contract by acting in an unauthorised manner – for example by copying music or video file which is protected by copyright.
- Property Law: Cryptocurrencies such as Bitcoin can be thought of as a set of smart contracts which enforce property law. Cryptographic techniques are used to ensure that only the owner of a digital token such as a bitcoin can spend it. Several decentralized asset exchanges already exist, which broaden out the range of asset so that many different digital assets can be traded on a single block chain. The same principle can also be extended to physical products with electronic controls or embedded microchips.
- Financial Services: Cryptocurrency obviously opens up a wide range of different use case for smart contracts which wouldn’t otherwise be possible. For example, systems such as the one used by BurstCoin are able to run auctions which automatically check for the highest bidder within a set time limit and refund everyone else, automatically transfer dormant funds, or run a decentralized lottery. This kind of smart contract only takes very simple numerical values as inputs, performs purely mathematical evaluations, and outputs a financial transaction through a cryptocurrency protocol. Another example would be Bitshares’ pegged assets, the creation of which by traders requires collateral to be put into a contract which has the power to sell that collateral if the market moves against its owner.
- Credit Enforcement An extension of property law, and a classic example of how smart contracts can be used in the real world, is credit agreements which disable your product if you fail to make your repayments. For example, you might imaging a future in which you buy a new car on credit, you fail to make the repayments, and your car simpy locks its doors and drives itself back to the showroom. Most electric products could be fitted with a ‘kill switch’ which disabled them if a simple condition is not met – such as a payment being made through a public channel such as a cryptocurrency blockchain.
- Oracle contracts: The main limitations to what can be done with smart contracts is that a computer program cannot easily and reliably tell what is happening in the physical world or who is telling the truth. Checking whether a bitcoin payment has been made is a simple task which is suitable for a computer program to do, but most real-world contracts and situations (for example: was a product really delivered to someone? Did a freelancer deliver work that met the company’s stated requirements?) are much harder for a computer program to evaluate. A smart contract’s execution is only as good as the inputs it takes in, and it may be difficult to find inputs which are sufficient to the job which both parties trust. One solution to this is to have oracles – online services providers whose job is to broadcast data which can be used as inputs by smart contract makers. For example, an oracle may broadcast new entires on the government registry of deaths, to be used by contracts executing wills, or the results of a football match, to be used in settling gambling bets. This method is used by Ripple’s Codius smart contracting platform
- Double Deposit Method: Some of the first working examples of smart contracts in the realm of cryptocurrency used the double deposit method pioneered by BitHalo and BlackHalo. This deceptively simple, but still very powerful method, is ideally suited to use with cryptocurrency. When entering into a contract such as this each person is required to make a cryptocurrency deposit into the contract’s program. This program has a set time before it expires. If the people involved in the contract cannot come to an agreement over how to proceed before the contract expire the funds are ‘burned’ – which means sending them to an address which nobody knows the private key for, effectively making them unspendable. The program itself doesn’t, therefore, make any attempt to decide whether each party has lived up to their obligations or who should do what to fulfill the terms they agreed to. But what it does do is to make it impossible for anybody to make a profit by cheating the other person – by ensuring that by breaking the contract they stand to lose exactly as much as they could gain. It also pushes all parties to put maximum effort into dispute resolution to comes to an agreement everyone can accept before the timer runs down and their funds are burned.
Smart Contract Platforms
The following are all protocols or platforms which can be used to create smart contracts.
Mwongozo wa Mwanzoni wa Mikataba ya Smart: Jinsi ya Kufuata Njia ya Mantiki Kupitia Uchaguzi wa Huduma Bora za Uchimbaji wa Wingu mnamo 2021 "Kama ilivyoelezwa hapo juu, ""Smart Contract"" ni kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu cha kifungu." Mikataba ya Smart imeandikwa kama kanuni ya programu ambayo inaweza kuendeshwa kwenye kompyuta badala ya lugha ya kisheria kwenye hati iliyochapishwa. Kanuni hii inaweza kufafanua sheria kali na matokeo kwa njia ile ile ambayo hati ya kisheria ya jadi ingefanya, ikisema majukumu, faida na adhabu ambazo zinaweza kuwa na sababu kwa upande wowote katika hali tofauti. Lakini tofauti na mkataba wa jadi, inaweza pia kuchukua habari kama pembejeo, kusindika habari hiyo kupitia sheria zilizowekwa katika mkataba, na kuchukua hatua yoyote inayohitajika kama matokeo. Ni nini uhakika katika mikataba smart? Lengo kuu la kubuni mikataba ya smart ni kuwezesha watu kufanya biashara na kufanya biashara na wageni, kwa kawaida kupitia mtandao, bila haja ya tovuti kubwa ya mamlaka ya kati. Hii ni muhimu kwa sababu tatizo kuu na ununuzi online, kuajiri watu juu ya mtandao, na kwa ujumla kufanya biashara na wageni juu ya mtandao ni suala la uaminifu. Biashara nyingi huhitaji jambo fulani la kuaminiana. Kwa mfano, kama mimi kununua kitu katika duka online mimi nina imani kwamba wao itabidi kutuma kwangu baada ya mimi kufanya malipo, na kama wao kufanya kutuma kwangu wao ni imani mimi si kugeuka malipo yangu kadi ya mikopo kuchukua wote fedha na kuchukua bidhaa bure. Hadi sasa matukio kama haya yametatuliwa na pande zote mbili kwenda kupitia maeneo makubwa maarufu ambayo wote wanaamini. Kwa mfano, moja ya faida kubwa ya mtandao ni kwamba inawezesha watu wa kawaida kwa urahisi kununua na kuuza vitu kati ya kila mmoja. lakini njia pekee tumepata kutatua tatizo la uaminifu ni kwa ajili ya wengi wa biashara hii p2p katika dunia nzima ya magharibi kwenda kupitia moja kubwa virtual-monopoly tovuti aitwaye eBay. Si tu kwamba tovuti hizi kubwa za waingiliano zinatoza ada kubwa kwa huduma zao, pia zinaweka mipaka na udhibiti wao wenyewe juu ya nini na jinsi watu wanavyouza, kwa hivyo wakipunguza sana uhuru wetu wa biashara. Kwa kutatua tatizo la uaminifu bila haja ya waingiliaji, mikataba ya akili inaweza kupunguza gharama za biashara, kupunguza bei za watumiaji, na kuongeza uhuru wetu wa kufanya biashara zetu kwa njia yoyote tunayoona inafaa. Aina na Mifano ya Mkataba wa Smart - Kuzuia Uvunjaji: Mfano wa mapema na rahisi wa mkataba wa smart ni Usimamizi wa Haki za Dijiti au teknolojia za DRM. Aina hii ya mkataba haichukui au usindikaji pembejeo, lakini tu kutekeleza yenyewe kwa kufanya ni vigumu kwa ajili yenu kuvunja mkataba kwa kutenda kwa njia isiyoidhinishwa - kwa mfano kwa kunakili muziki au video faili ambayo ni kulindwa na hakimiliki. "Kulingana na sheria za mali isiyohamishika, Bitcoin inaweza kuwa ""mkataba wa akili"" ambao unalazimisha sheria za mali." Utafiti wa cryptographic unaonyesha kwamba tu mmiliki wa chapa ya dijiti, kama vile Bitcoin, anaweza kutumia. Pia kuna kubadilishana kwa mali kadhaa zilizojengwa, ambazo zinaongeza aina ya mali ili mali nyingi za dijiti ziweze kuuzwa kwenye mnyororo mmoja wa block. Kanuni hiyohiyo yaweza pia kupanuliwa kwa bidhaa halisi zenye udhibiti wa kielektroniki au michoro iliyoingizwa. - Huduma za kifedha: Cryptocurrency wazi anafungua mbalimbali ya kesi tofauti ya matumizi kwa mikataba smart ambayo ingekuwa vinginevyo haiwezekani. Kwa mfano, mifumo kama ile inayotumiwa na Burstcoin inaweza kuendesha mnada ambao huangalia moja kwa moja kwa mnunuzi wa juu zaidi ndani ya kikomo cha muda na kurudisha kila mtu mwingine, kuhamisha fedha za kimya moja kwa moja, au kuendesha bahati nasibu. Mkataba wa smart huchukua tu maadili ya nambari rahisi kama pembejeo, hufanya tathmini za hisabati tu, na hutoa shughuli za kifedha kupitia itifaki ya cryptocurrency. Mfano mwingine ni Bitshares, ambayo inahitaji dhamana ili kuingizwa katika mkataba ambao una nguvu ya kuuza dhamana hiyo ikiwa soko linaenda dhidi ya mmiliki wake. Mkataba wa mkopo ni upanuzi wa sheria ya mali, na mfano wa kawaida wa jinsi mikataba ya akili inaweza kutumika katika ulimwengu halisi, ni mikataba ya mkopo ambayo inazuia bidhaa yako ikiwa unashindwa kufanya malipo yako. Kwa mfano, unaweza kufikiria wakati ujao ambapo unanunua gari jipya kwa mkopo, unashindwa kulipa malipo, na gari lako la kawaida hufunga milango yake na kuendesha gari lenyewe kurudi kwenye showroom. Bidhaa nyingi za umeme zinaweza kuwa na "kill switch" ambayo huzifunga ikiwa hali rahisi haikutimizwa - kama vile malipo yanayofanywa kupitia njia ya umma kama vile cryptocurrency blockchain. Mipaka ya Oracle: Mipaka ya msingi ya mikataba ya smart ni kwamba programu ya kompyuta haiwezi kwa urahisi na kwa uaminifu kusema nini kinachotokea katika ulimwengu wa kimwili au ni nani anayesema ukweli. Kuangalia kama malipo ya Bitcoin imefanywa ni kazi rahisi ambayo inafaa kwa programu ya kompyuta kufanya, lakini mikataba na hali nyingi za ulimwengu halisi (kwa mfano: bidhaa ilitolewa kwa mtu? Je, freelancer alitoa kazi ambayo ilikutana na mahitaji ya kampuni iliyotolewa?) Ni vigumu sana kwa programu ya kompyuta kuamua. Utekelezaji wa mkataba wa akili ni mzuri tu kama pembejeo inachukua, na inaweza kuwa vigumu kupata pembejeo ambazo ni za kutosha kwa kazi ambayo pande zote mbili zinaamini. Suluhisho moja kwa hili ni kuwa na oracles - watoa huduma mtandaoni ambao kazi yao ni kutangaza data ambayo inaweza kutumika kama pembejeo na watengenezaji wa mkataba smart. Kwa mfano, mwandishi wa habari anaweza kutangaza habari mpya katika orodha ya serikali ya vifo, ili itumiwe na mikataba ya kutekeleza matakwa, au matokeo ya mechi ya mpira wa miguu, ili itumiwe katika kusuluhisha bets za kamari. Njia hii hutumiwa na Ripple's Codius smart contracting platform - Double Deposit Method: Baadhi ya mifano ya kwanza ya kufanya kazi ya smart mikataba katika ulimwengu wa cryptocurrency kutumika njia ya amana mara mbili pioneered na BitHalo na BlackHalo. Njia hii ya udanganyifu rahisi, lakini bado yenye nguvu sana, inafaa sana kwa matumizi na cryptocurrency. Wakati wa kuingia katika mkataba kama huu kila mtu inahitajika kufanya amana cryptocurrency katika mpango wa mkataba. Programu hii ina muda uliowekwa kabla ya kumalizika. Ikiwa watu wanaohusika katika mkataba hawawezi kufikia makubaliano juu ya jinsi ya kuendelea kabla ya mkataba kumalizika, fedha hizo "zitateketezwa," ambayo inamaanisha kuzipeleka kwa anwani ambayo hakuna mtu anayejua ufunguo wa kibinafsi, kwa ufanisi kuifanya isiweze kutumiwa. Kwa hiyo, programu yenyewe haijaribu kuamua kama kila chama kimetimiza wajibu wake au ni nani anayepaswa kufanya nini ili kutimiza masharti waliyoyakubaliana. Lakini kile kinachofanya ni kufanya iwe vigumu kwa mtu yeyote kupata faida kwa kumdanganya mtu mwingine - kwa kuhakikisha kwamba kwa kuvunja mkataba wao kusimama kupoteza hasa kama wengi kama wangeweza kupata. "Hii pia inawasukuma pande zote kuweka juhudi za juu katika utatuzi wa mzozo ili kufikia makubaliano ambayo kila mtu anaweza kukubali kabla ya muda kukamilika na fedha zao kuchomwa. """ Smart Mkataba Platforms ni mfululizo wa mifumo ya mawasiliano ambayo inaweza kutumika kwa ajili ya kuunda smart mikataba.