⬆️ UPVOTED | DECODING SMART CONTRACTS (PART II)
Last week, I delved into the historical backdrop to smart contracts and the general concept of “code is law”, starting off with a brief overview of the nature of contracts and contract law in the real world (or meatspace, as it is sometimes rather disparagingly known); continuing on through the work of early crypto pioneer and legal scholar Nick Szabo, whose life journey led him to prioritise ‘trust-minimisation’ as a guiding principle; and culminating in the birth of the world’s very first smart contract platform in 2015, as detailed by Vitalik Buterin in the ground-breaking 2014 Ethereum white paper. This week, we’re going to get into the actual nuts and bolts of what smart contracts are, how they operate, what applications they serve, and more generally why they are so important — alongside what the existing pain points and limitations are…
But first: we all stand on the shoulders of giants, so the expression goes. And the world of crypto is no different. So, before we get started on the business of decoding smart contracts, it’s worth contextualising this topic in relation to the prime-mover in the crypto space — Bitcoin…
HORSES FOR COURSES: ONE-TRICK PONIES AND OPEN SYSTEMS
Bitcoin was a monumental breakthrough because it provided a workable, distributed (decentralised) solution to the “double-spending problem” (in computing circles often known as the Byzantine generals problem) — i.e. it provided a viable, sustainable mechanism for transferring value over a peer-to-peer network without the need for a trusted third-party (such as a financial institution) to take responsibility for maintaining and preserving the authenticity of the ledger.
So, the pseudonymous Satoshi Nakamoto effectively built the crypto equivalent of the first railroad, but it was a railroad that specialised in doing one thing: moving Bitcoin (the ascribed digital unit of value of the network) from Point A to Point B securely and trustlessly. This in and of itself was a huge deal, and represented a major unlock, but it didn’t provide any scope for programmability — i.e. for anyone external to harness the Bitcoin network to build anything new directly on top of it. In other words, Bitcoin was (and to a large extent remains) a bit of a one-trick pony. Having said that, Bitcoin’s single trick (to mix metaphors for a moment) was a quadruple Axel high jump.
Amongst the first wave of Bitcoin’s early adopters was a Russian-Canadian computer programmer called Vitalik Buterin, who (along with a handful of his computer geek contemporaries) immediately recognised the white-hot power and potential of this new technological substrate… but who wanted to tinker and build lots of neat stuff on top of it (as all good programmers do).
Including (for example): enabling the ownership of non-fungible assets such as domain names; and the creation of more complex applications which involved “having digital assets being directly controlled by a piece of code implementing arbitrary rules” — otherwise known (owing to the prior work of the aforementioned Nick Szabo) as "smart contracts".
So, Vitalik and his cohort frenetically set about constructing a next-generation blockchain — taking everything that Bitcoin had accomplished (including using the bulletproof ‘Proof of Work’ consensus mechanism) and upgrading it into a programmable, permissionless innovation machine (or a “smart contract platform” in the terminology de nos jours). This was a wildly revolutionary step — in many respects of equal significance to Bitcoin itself, for reasons I hope will become clear as we get into the details hereafter. Because these self-executing (smart) contracts, powered by blockchain technology, have the potential to completely revolutionise the way agreements are made and enforced across virtually all industries.
And it’s why Ethereum - even if it doesn’t manage to maintain its competitive edge against some of the newer smart contract platforms - will always be up there with Bitcoin in the crypto hall of fame… along with Ethereum’s wunderkind founder, Vitalik Buterin.
Yes, that’s all very well, I hear you say — but what about all that nuts and bolts stuff you promised to get in to?…
SMART CONTRACTS: A BRIEF INTRODUCTION
Smart contracts are essentially pieces of code that can automatically execute predefined actions in a deterministic manner. Typically stored and executed on a type of blockchain known as a smart contract platform, smart contracts aim to establish trust and security by eliminating the need for intermediaries in decision-making processes. As discussed in Part I last week, human beings are often the weakest link in any system, plus they like to take their cut — so removing them completely from the intermediation process and replacing them with software code can be considered one of crypto’s greatest superpowers (as indeed it is with Bitcoin).
So, in essence, a smart contract is merely a set of rules and regulations, translated into code, which automatically executes predetermined actions when specific conditions are met. Just imagine a traditional contract, but instead of relying on intermediaries like lawyers or banks, the contract executes itself based on the agreed-upon terms. This ‘self-execution’ is powered by the decentralised nature of blockchains — ensuring transparency and eliminating the need for the involvement of a centralised authority.
The components of a smart contract are relatively straightforward. They comprise:
Conditions (the set of rules that need to be met);
Actions (the corresponding outcomes when those conditions are satisfied).
In traditional software terms, this is achieved by using conditional statements — i.e. operating on the principles of "if-then" semantics; which perform different computations or actions depending on whether a programmer-defined Boolean condition evaluates to true or false. It’s important to note that any smart contract may also interact with other smart contracts (unless it's restricted in code), thus enabling more sophisticated proxy design patterns.
Smart contracts are typically written in bespoke programming languages such as Solidity (Ethereum’s native programming language), which are designed (from the ground up) for writing and deploying smart contracts. However, as the space matures, the degree of interoperability between smart contract platforms and more traditional technology stacks is evolving. For example, C/C++ has already been used to write smart contracts for smart contract platforms operating on the EOS.IO blockchain protocol.
THE IMPORTANCE AND ADVANTAGES OF SMART CONTRACTS
Smart contracts have the potential to revolutionise processes across virtually all industries. One of their key advantages is efficiency through automation — whereby tasks that have traditionally required manual intervention can now be executed seamlessly, thus reducing the time and resources required.
Transparency and trust are also paramount. Smart contracts are immutable, and the decentralised nature of blockchain ensures that all parties involved have access to the same information — mitigating the risk of fraud or manipulation. And as previously outlined, the removal of intermediaries in contractual processes reduces costs and time wasted, both expediting transactions and making them more cost-effective.
Reusability is another key factor. Unlike traditional contracts, which are often one-time-use documents, smart contracts, once deployed on a blockchain, can be replicated and reused for similar transactions with minimal effort. This reusability factor is crucial for several reasons. Firstly, it saves time and resources, as developers can leverage existing, well-tested code — rather than starting from scratch for each new contract. Secondly, it enhances consistency and reduces the likelihood of errors, as the same logic can be applied across multiple instances. And thirdly, reusing smart contracts promotes standardisation in contractual relationships — fostering a more efficient and interoperable ecosystem on blockchain platforms. This capability not only streamlines the development process but also contributes to the scalability and sustainability of blockchain-based applications and systems.
A KILLER APPLICATION: ESCROW TRANSACTIONS
In the real world, escrow-based transactions have a long history. And as with our etymological detour in Part I (concerning the nature of contracts themselves), it’s worth a brief pitstop to recap on the original context here.
From Wikipedia:
An escrow is a contractual arrangement in which a third party (the stakeholder or escrow agent) receives and disburses money or property for the primary transacting parties, with the disbursement dependent on conditions agreed to by the transacting parties. Examples include an account established by a broker for holding funds on behalf of the broker's principal or some other person until the consummation or termination of a transaction; or a trust account held in the borrower's name to pay obligations such as property taxes and insurance premiums. The word derives from the Old French word escroue, meaning a scrap of paper or a scroll of parchment; this indicated the deed that a third party held until a transaction was completed.
In a smart contract-based escrow transaction, however, two parties can bypass all the faffing about and engage directly in a secure exchange of assets or services on-chain — i.e. without the need to engage (and pay for the involvement of) a trusted third-party.
Here's a simple explanation of how it works:
Agreement
The two parties involved agree on the terms of the transaction. This could include details such as the item or service being exchanged, the price, and any specific conditions that need to be met.
Creation of smart contract
A smart contract is created on a blockchain platform, such as Ethereum. The smart contract contains the predefined terms and conditions of the agreement.
Funding the escrow
The party that initiates the transaction, often the buyer, funds the smart contract with the agreed-upon amount. This amount is held in escrow, meaning it is temporarily held by the smart contract until the conditions are met.
Verification of conditions
The smart contract is programmed to execute specific actions only when certain conditions are met. These conditions could include the successful delivery of goods or completion of services. The conditions are agreed upon by both parties in advance.
Release of funds
Once the conditions are met and verified by the smart contract (usually through an oracle or automated mechanism), the funds held in escrow are automatically released. This ensures that the seller receives payment only when the buyer has received the agreed-upon goods or services.
Dispute resolution (optional)
Some smart contracts include mechanisms for dispute resolution. If a dispute arises, the smart contract may have predefined steps for arbitration or resolution, ensuring a fair and transparent process.
Transaction completion
With the funds released and the conditions met, the smart contract completes the transaction. Both parties can verify the completion on the blockchain.
This simple class of smart contract can be used for a virtually infinite variety of financial applications as you can probably imagine — from automated payments, to asset purchases, to currency exchanges (token swaps), to loans (borrowing and lending), to insurance products, to sports betting, etc. You name it — and there’s probably an application for this class of smart contract. They are the very backbone of decentralised finance (DeFi) and have already led to the development of new financial and governance architectures, including decentralised exchanges (DEXs) that function as automated market makers (AMMs), and managing the finances of decentralised autonomous organisations (DAOs). Another rapidly emerging domain is Decentralised Science (DeSci), about which more another time. This Cambrian explosion of decentralised development is all underpinned by the power of smart contracts.
OTHER MAJOR USE CASES FOR SMART CONTRACTS
LEGAL AND GOVERNANCE
Digital Identity
Smart contracts can play a pivotal role in establishing and managing digital identities. Through a blockchain's decentralised architecture, individuals can maintain much more control over their personal information — granting access to specific elements by specific parties only under predefined conditions. This enhances privacy, reduces identity theft risks and allows for streamlined, consent-based interactions in various digital scenarios.
Voting Systems
Transforming the landscape of democratic processes, smart contracts can provide a secure and transparent foundation for voting systems. Voters' identities and ballots can be encrypted over the blockchain, ensuring anonymity and preventing fraud. Smart contracts can be programmed to automatically tally votes and declare results, minimising the potential for human error (and fraud), thus enhancing the integrity of the electoral process.
SUPPLY CHAIN LOGISTICS
Transparency and Traceability
Smart contracts can introduce transparency and traceability within the supply chain management sector, enabling each step in the supply chain - from production to distribution - to be recorded on the blockchain. This immutable ledger ensures that stakeholders have real-time visibility into the provenance and movement of goods. Counterfeit prevention, quality control and ethical sourcing become achievable via a decentralised, transparent supply chain.
Automated Compliance
Ensuring adherence to regulatory standards can be an extremely complex task in supply chain operations. Smart contracts streamline this process by automating compliance checks. Contracts can be programmed to verify whether goods meet specific regulatory criteria at each stage of the supply chain. Any deviations can trigger alerts or adjustments — reducing the risk of non-compliance and facilitating smoother interactions with regulatory authorities.
THE GREAT LEVELLER: DATA QUALITY
So far, we’ve only addressed smart contracts in isolation. But smart contracts do not operate in a vacuum: in order to be deterministic, they require input data to function. For example, if a smart contract is being used to facilitate a currency swap - say someone wants to exchange Bitcoin (BTC) for Ether (ETH) on a DEX - then it needs to know what the current price for each of those assets is before being able to calculate the exchange rate and process the transaction. And since smart contracts must be able to source their data on-chain, they currently rely entirely on another major blockchain primitive — known as blockchain oracles.
This is another vast area, so I’m not even going to peel back the first layer of the onion here — but put simply, the basic principle of “garbage in, garbage out” applies. In other words, a smart contract is only as reliable as the data it is using. In reality, this already works remarkably well (albeit with some notable exceptions). And there are some very sophisticated (predominantly decentralised) blockchain oracle providers, such as Chainlink, who provide extremely resilient protocols for curating and distributing reliable on-chain data.
SECURITY PROBLEMS: BUGS AND HONEYPOTS
However, it’s fair to say that this transformative technology is not without its challenges. Security risks are a primary concern, especially given the irreversible nature of transactions on the blockchain. And if there is a bug in a smart contract, the ramifications can be catastrophic. Up-front smart contract auditing procedures have improved significantly since the early days of Ethereum, but if a bug in a smart contract is identified after it is deployed, whilst the original smart contract can in many instances be replaced with a new version, such revisions may introduce additional problems and complexities downstream (not least from a legal standpoint, about which more later). And as with other online software scenarios, if bugs exist and they are not identified, sooner or later they will be exploited by hackers.
One of the biggest problems in terms of security is that many deployed smart contracts act as honeypots. They may hold (for example in escrow) significant funds (as digital assets), which makes them a significant threat vector — since malicious actors are drawn to interrogate them for their weaknesses and exploit them. And on the basis that a system is only as strong as its weakest link, there are also other associated threat vectors — such as tampering with the integrity of the data on which they base their decisions.
It’s worth remembering - even in spite of some of the eye-watering losses already incurred as a result of faulty smart contracts - that we’re still very early-on in the development of this stuff. Ethereum, the world’s first smart contract platform, was only launched in July 2015 after all — less than 9 years ago. And a huge amount of development has taken place since then. Things are moving fast.
LEGAL & REGULATORY CONSIDERATIONS
Whilst smart contracts hold immense promise in transforming traditional systems (as outlined above), their widespread adoption faces significant legal and regulatory challenges. The current legal frameworks developed for traditional contracts may not seamlessly integrate with the decentralised and automated nature of smart contracts.
Since these contracts are self-executing and often operate on decentralised blockchain platforms, the lack of a central authority to arbitrate disputes raises questions about how legal systems would handle breaches or disputes.
Moreover, the immutable nature of the blockchain is a double-edge sword. Once deployed, smart contracts are resistant to alteration, requiring careful consideration and meticulous coding to avoid vulnerabilities. This rigidity contrasts with the adaptability often needed in legal agreements — where unforeseen circumstances may require modifications.
In order for smart contracts to gain widespread acceptance beyond the existing crypto ecosystem, there is a pressing need for the development of clear and comprehensive legal frameworks. Regulatory bodies must address issues related to contract validity, dispute resolution and the recognition of smart contracts within existing legal structures.
REAL-WORLD DEPLOYMENT AND SCALABILITY CHALLENGES
The real-world deployment of smart contracts also faces scalability challenges beyond the current crypto ecosystem. Scalability issues arise when these contracts need to handle a high volume of transactions. Many existing blockchain platforms, including Ethereum, face limitations in terms of transaction processing speed and cost — hindering their suitability for large-scale applications.
I recently wrote about the current scalability issues in a piece entitled ‘Vitalik’s Trilemma and the Imminent Rise of the Ethereum Killers’ — which you can check out here. But in short: this bandwidth problem is just a result of the fact that it’s still very early days. Blockchain technology is rapidly scaling to meet the demand for faster networks, higher throughput and lower transaction costs.
Interoperability between different blockchain networks and legacy systems is another hurdle. For smart contracts to seamlessly integrate into existing business processes, standards for cross-chain compatibility and interaction with traditional databases need to be established. Bridging the gap between decentralised smart contracts and centralised legacy systems is essential for achieving widespread adoption in industries where a hybrid approach is necessary.
Addressing these legal and scalability challenges will require a collaborative effort involving legal experts, technologists, industry stakeholders and regulatory bodies. This is already happening — but these things take time (and rightly so). Striking a balance between innovation and compliance will be pivotal in unlocking the full potential of smart contracts in real-world applications, in order to facilitate their broader adoption (at scale) across diverse industries and ecosystems.
CONCLUSION
It’s been a long run, so I’ll spare the horses in concluding: the disruptive potential of smart contracts is significant. They challenge many traditional models of operation — offering a glimpse into a future where decentralised, automated systems fundamentally redefine the way we engage in agreements and transactions in the digital age.
And as this technology matures and the regulatory frameworks evolve, I think it’s a racing certainty that smart contracts will go from being considered a novel, crypto-centric technology to playing a truly transformative role in reshaping the landscape of contractual agreements and transactions across almost every sector — at a global scale.
BLACKROCK’S BITCOIN ETF FIRST TO REACH $2B IN AUM
In brief:
The BlackRock iShares Bitcoin ETF (IBIT) on Friday became the first of the recently launched spot bitcoin products to reach $2 billion in assets under management (AUM). This doesn't include Grayscale's GBTC, which had nearly $30 billion in AUM at the time of its conversion from a closed-end fund to a spot ETF.
Investors added about $170 million to IBIT on Thursday, with the fund purchasing nearly another 4,300 bitcoin (BTC), pushing total tokens held to 49,952. With the price of bitcoin rising well above the $40,000 level early Friday, that brought AUM to above $2 billion.
Link to full story: https://www.coindesk.com/markets/2024/01/26/blackrocks-bitcoin-etf-first-to-reach-2b-in-aum/
RESEARCHERS USE BLOCKCHAIN NETWORK TO SIMULATE THE DAWN OF LIFE ON EARTH
In brief:
Polish scientists have created a vast network to simulate the origins of life on Earth. They used “prebiotic feedstocks” like water and nitrogen to trace how early compounds eventually led to human existence.
The researchers, operating out of the Institute of Organic Chemistry in Poland, first published an article in Science in 2020 in which they created a version of this network — albeit one with limitations.
The Golem network, operating as a layer-2 distributed computing platform, enabled the researchers to construct a network that was 100,000 times larger than their initial attempt.
In a paper published in the academic journal Chem, the researchers detail how this “counterintuitive marriage” between crypto and origins of life research allowed them to pull off a far bigger version of the network without needing access to supercomputing resources.
Link to full story: https://blockworks.co/news/blockchain-replaces-supercomputer-golem
BITWISE BITCOIN ETF WALLET ATTRACTS INSCRIPTIONS AND RARE SATS DONATIONS
An intriguing collision of two very different worlds — crypto and TradFi. I can completely understand why people might choose to leave smooth pebbles and little origami birds by the graves of people like Sartre or Wittgenstein, but randomly sending digital assets to the wallet of a spot Bitcoin ETF provider? Sacrebleu!
In brief:
Asset management firm Bitwise made the Bitcoin address of its spot BTC exchange-traded fund (ETF) public on Jan. 24, becoming the first of the 10 spot BTC ETF issuers to do so. The Bitcoin wallet address has received multiple tips and donations within hours of being public, including some Bitcoin ordinals and rare sats.
The wallet address currently holds inscriptions donations worth $6,083 and holds a total of over 16,000 inscriptions. These inscriptions include two RSIC airdrops, one Bitcoin Punk, one Bitcoin Burials, one Quadkey, and several others. The account also holds thousands of BRC-20 inscriptions; however, there are no valid/active BRC-20 balances in the account.
Link to full story: https://cointelegraph.com/news/bitwise-bitcoin-etf-wallet-attracts-inscriptions-rare-sats-donations
WHY THE TORNADO CASH TRIAL IS IMPORTANT (AS IT SEEKS DONATIONS)
The outcome of this trial is likely to have far-reaching implications concerning code as free speech. If the developers are convicted, it will set a disastrous precedent for criminalising software developers based on what other people choose to do with their code. The stakes are high, and so the cryptosphere is donating to the defense legal fund…
In brief:
Tornado Cash developers are gearing up to face money laundering charges in the Netherlands and the U.S.
Ahead of the trials, an activist group has launched a fundraiser to aid their defense.
The outcome of the cases is likely to have far-reaching impacts on open source and Web3 development.
Link to full story: https://dailycoin.com/why-tornado-cashs-trial-important-it-seeks-donations/
‘RAZZLEKHAN’: AMAZON IS TURNING $4B BITFINEX BITCOIN HEIST INTO FEATURE FILM
In brief:
Amazon MGM Studio is developing a movie based on the life of crypto thief Heather “Razzlekhan” Morgan and her husband Ilya Lichtenstein, who in 2022 were charged with conspiracy by the U.S. Department of Justice related to a $4 billion heist and money laundering scheme.
First reported by Deadline on Friday, the still-unnamed film will be helmed by director Hannah Marks (“Don’t Make Me Go”), who also wrote the script, and co-produced by “Riverdale” alum Lili Reinhart. The script is inspired by a New York Times article from 2022, and the publication is participating in the production through partner Anonymous Content.
Link to full story: https://decrypt.co/214436/razzlekhan-amazon-bitfinex-bitcoin-heist-movie
That’s all for now — until next week! 👋
Great article Brian! Worth every second! We are moving forward on our platform and I’m excited to see how we can collaborate brother! Namasté