The University of Tokyo Endowed Chair in Blockchain Innovation - A Deep Dive into Smart Contract Technology
Table of Contents
- How Smart Contracts Technically Work
- Technical Challenges and Solutions
- Metacontracts and state-of-the-art technology
- Glossary of Technical Terms
- Summarize
- Related article (Blockchain Public Lecture Series):
Blockchain Innovation Endowed Chair at the University of Tokyois a rare opportunity to learn in depth about "smart contracts," the core technology of blockchain. This article will focus on the technical aspects of the course, how smart contracts work, challenges, and new approaches.
How Smart Contracts Technically Work
1. smart contract execution environment: EVM (Ethereum Virtual Machine)
Ethereum smart contracts run on EVM, a virtual machine, which is the environment in which the nodes of the blockchain execute their programs. The following are its technical features
- stacked architecture
Operations are performed in 32-byte increments and calculations proceed on the stack. Example: If theADD
,sub
,CALL
and other opcodes. - gas restriction
Running a program in EVM requires a unit of "gas". Gas is consumed in response to a computation or storage operation, and the sender of the transaction bears the cost.- Example: 21,000 gas is needed just to store 32 bytes of data in storage.
- The current block gas limit is 30M gas.
- account model
Two types of accounts exist at EVM.- EOA (externally owned account): Managed by a private key, issuing transactions.
- CA (Contract Account): Has code and can be called from other contracts.
2. classification of smart contracts and their applications
- UTXO type
Signs each transaction and manages the state independently. Mainly used for simple payments such as Bitcoin. - VM type
Computes state across the entire network and handles complex processing. Ethereum and Solana are typical examples.
Practical example:.
- DeFi (decentralized finance): Automated lending and exchanges (e.g. Uniswap, Aave).
- NFT Marketplace: Token management and trading (e.g. OpenSea).
- DAO: Automate governance (e.g. MakerDAO).
Technical Challenges and Solutions
1. vulnerability of the contract
The immutability of smart contracts makes them difficult to change once deployed. This can lead to bugs and security issues that can cause irreparable damage.
- Famous examples:.
- The DAO case: approximately $60 million in ETH was stolen in a reentrancy attack.
counter-measure
- Audit
Code review by a professional organization, utilizing OpenZeppelin and Immunefi. - Introduction of Check Patterns
checks-effects-interactions
pattern is employed and the state change is made prior to the external call.
2. gas efficiency optimization
Processing in EVM is costly, especially storage operations, which are the main source of gas consumption.
solution
- Gas Golfing
Technology to optimize codes and reduce gas consumption. - Layer 2
Reduce costs by using scaling techniques such as Optimistic Rollup and ZK-Rollup.
3. external dependencies and use of oracles
Smart contracts do not have direct access to external data sources. This places restrictions on obtaining, for example, pricing data.
solution
- Use of Oracle
Import external data using an Oracle service such as Chainlink. - virtual oracle
Some distributed applications perform alternative calculations on internal data.
Metacontracts and state-of-the-art technology
Meta Contract
Meta Contractis a framework that leverages the ERC-7546 UCS architecture to achieve both flexibility and efficiency.
Funciton
- Function-Level Upgradeability
Contract features can be upgraded individually. - Cloneability
Duplicate templates for efficient deployment of multiple contracts. - uniform management
Centralized management of numerous contracts.
Applications
- Decentralized Wallet (Contract Wallet)
- Customizable wallet with individual user status.
- DAO and DeFi management
- Simplify governance of large organizations.
Glossary of Technical Terms
- Gas: A unit of measure of the cost of executing a smart contract.
- Reentrancy Attack: An attack in which the same function is called again in the middle of processing, causing an unexpected state change.
- Oracle (Oracle): A mechanism for providing external data to a smart contract.
- Meta Contract: A framework for efficiently developing and managing large-scale smart contract systems.
Summarize
The University of Tokyo's Blockchain Innovation Endowed Chair offers a comprehensive study of smart contracts, from technical fundamentals to applications. Particularly appealing is the opportunity to be exposed to the latest technological trends in security and meta-contracts. We hope that the knowledge gained through this course will be used by our readers in their future projects.