What's the deal with Smart Contracts?
Simon Kirnberger
Product Owner (Custody), TanganySmart Contracts are often portrayed in the crypto world as a cure-all that can solve any problem. But what are Smart Contracts, and why are they neither "smart" nor contracts?
What are Smart Contracts and what are they not?
Smart Contracts are special programs or scripts that run on a blockchain. They allow business logic to be executed automatically when certain predefined conditions are met. Essentially, they are self-executing contracts whose terms are set in code. These scripts are immutable and transparent once implemented on the blockchain, meaning they cannot be modified, and every action is visible to all participants.
An illustrative example to clarify the concept of Smart Contracts is the comparison with a vending machine. Such a machine operates on a simple principle: as soon as a person inserts the required amount and selects a drink, the machine checks if the amount entered is correct and then dispenses the desired drink. There is no need for a human intermediary to monitor or approve the process. The machine itself ensures that all conditions are met before proceeding to action.
Similarly, Smart Contracts on the blockchain accept inputs (such as cryptocurrency or tokens) and automatically perform actions when the defined criteria are met.
These actions can be that one can perform the exchange of ETH into a stablecoin at the current market price with a Smart Contract without needing a central party. Or that token dividends are distributed to all wallets that own an eligible NFT.
To continue with the vending machine example, the smart contract is operated in the same way. The method mint is selected, and then the necessary information is "inserted," signed, and in the smart contract, as shown in the diagram, 10 Cola tokens are created for Anna's wallet. This information is stored on the blockchain and is publicly accessible.
If Anna wants to send a Cola token to Bob because she wants to do something nice for him, she must interact with the smart contract again. She needs to call the method transfer, define the number of tokens, and specify the recipient. The smart contract will internally transfer the tokens, resulting in a new balance.
This example demonstrates that Smart Contracts are neither "smart" in the sense of artificial intelligence nor "contracts" in the classical legal sense. They are rather automated mechanisms based on predefined logical conditions to carry out transactions and processes without human intervention.
What can a Smart Contract be?
In addition to simple "Hello World" Smart Contracts, it goes up to complex DeFi Smart Contracts like Uniswap v4, which, as decentralized exchanges (DEXs) and automated market makers (AMMs), has handled trillions of USD in asset transfers.
Moreover, tokens like the USDT stablecoin or NFTs like the Cryptopunks are based on Smart Contracts. The basis for this is so-called token standards like ERC-20 for fungible tokens and ERC-721 for non-fungible tokens.
The ERC-20 token is the basis of many cryptocurrencies and is considered the reason why DeFi is possible.
This standard defines a set of rules that a Smart Contract must meet to act as an ERC-20 token. These include basic functions such as transfer, to send tokens from one address to another, balanceOf, to query the token balance of an address, and approve and transferFrom, which allow managing tokens on behalf of another user. In addition to the core functions, there is the possibility to add more, such as minting or burning of tokens, where new tokens are created or existing ones are destroyed. This process occurs, for example, with stablecoins where the provider mints a 1USDT token for a deposit of 1 US dollar and credits it to the depositor, while the token burning process again creates the possibility to pay out money in the real world.
What makes Smart Contracts so valuable?
Smart Contracts alone are not initially a specialty, as the logic of smart contracts exists in other areas as well. However, what makes smart contracts special is their integration with blockchain. In a centralized system's smart contract, one cannot assume that the code hasn't been altered in the background or that the other party may not be able to fulfill the condition because, for example, they do not have enough money. The transparency and immutability created by the blockchain can achieve a new level of trust where trust-creating intermediaries are not needed.
One example is Decentralized Finance (DeFi): In the world of finance, smart contracts enable the creation of DeFi platforms where users can lend, borrow, trade, and earn interest on their assets without the need for traditional financial institutions. For instance, a user can lend their cryptocurrency through a smart contract that automatically matches lenders with borrowers, sets interest rates, and ensures that collateral is secured. This process eliminates the need for banks as intermediaries and reduces the costs and barriers typically associated with lending and borrowing.
Another way of how smart contracts can create value is through the tokenization of real-world assets, linked to DeFi. Consider the tokenization of real estate, a sector traditionally marked by high entry barriers and complex transactions.
By using smart contracts, real estate properties can be divided into digital tokens that represent shares of the property. These tokens can then be traded on DeFi platforms, allowing investors to buy and sell fractions of properties without the need for traditional real estate brokers or financial institutions. This process lowers the entry threshold for investors, making real estate investment more accessible to a broader audience.
For instance, a smart contract can automate the distribution of rental income among token holders, proportionate to their ownership. This ensures transparency and timely payments, reducing administrative overhead. Furthermore, these tokens can be used as collateral within DeFi platforms to secure loans or participate in other financial activities, enhancing liquidity and creating a more interconnected financial ecosystem.
This approach not only democratizes access to real estate investment but also integrates real-world assets into the DeFi space, offering new opportunities for portfolio diversification and financial innovation.
In conclusion, smart contracts are transforming how we handle transactions by embedding trust in code and removing traditional intermediaries. They're reshaping industries from finance with DeFi to real estate through tokenization, proving essential in the evolving digital economy. As their applications continue to grow, smart contracts are proving to be a cornerstone of the evolving digital economy.
Bonus Tutorial
For the ones who would like to have work with Smart Contracts can find here short introductions how to deploy a smart contract and how to interact with a smart contract
How do you deploy a Smart Contract?
Creating your own Smart Contract is easier than you might think, as there are many tools available, especially for EVM blockchains like Ethereum.
On OpenZeppelin, you can copy and customize templates of Smart Contracts like ERC-20 from https://www.openzeppelin.com/.
On Remix, this code can be compiled; at this step, the human-readable code is turned into machine-readable code consisting of a series of numbers and letters. Visit https://remix.ethereum.org/.
In the final step, the code is transmitted to the blockchain, similar to a normal Ethereum transaction in that storing the Smart Contract on the blockchain costs money, i.e., ETH on Ethereum or Matic on Polygon. The deployment can happen manually via Meta Mask and Remix or also via the Tangany Custody API.
How do you interact with a Smart Contract?
Smart Contracts have two types of methods, Read to query information such as with BalanceOf, where it can be queried for individual addresses how many tokens of the Smart Contract belong to which wallet, and Write to change states within a Smart Contract such as with the Transfer method.
Querying Smart Contract data or posting Smart Contract transactions is possible via Etherscan by searching for the Smart Contract address and in the next step connecting one's hot wallet such as Meta Mask and signing the process.
There are also ways to automate these processes that can be done manually with MetaMask using APIs; here, Tangany provides the ability through the Custody API to interact with any Smart Contract methods, whether Read or Write.
There is a wide range of courses on smart contracts, here is a small selection of
courses that are suitable for delving deeper into smart contracts
https://chain.link/bootcamp is also suitable for individuals who are not developers but want to gain technical knowledge. You will already deploy Smart Contracts in the first session.
https://www.alchemy.com/university/courses/solidity is very technical and suitable for individuals who want to develop smart contracts on Ethereum.
Tangany is a specialist in handling smart contracts. Our Custody solutions can securely manage any type of token, including ERC-20, as well as NFT standards such as ERC-721 and ERC-1155. This is applicable regardless of whether the token represents tokenized real estate or utility tokens like Uni from Uniswap. Furthermore, we enable interaction with smart contracts at the method level and facilitate their deployment. Our Solution is used by tokenizers, Corporations, and banks to have a secure and scalable Solution.
For any inquiries, please feel free to contact us. https://tangany.com/contact-us
Weiterlesen
Weiter lernen und weiterlesen
Bleiben Sie auf dem Laufenden über die Welt der Kryptoregulierung und erhalten Sie Neuigkeiten über Tangany.