At Blocto, we aim to make blockchain apps (dApps) simple and accessible for general users. As a cross-chain wallet and DeFi aggregator, we constantly look into new blockchains, cross-chain solutions, and dApps to see how we can add value to our ecosystem.
In our recent explorations, Aptos’s vibrant dev community and a strong team aiming to give former Meta’s project Diem a second life, catch our attention. Listening to the Blocto community’s voice to have Blocto go on Aptos, we’re now bringing Blocto App to Aptos and building our user-friendly SDK on Aptos for a frictionless experience.
In this article, I will briefly go through the novel features of Aptos: the Move language and resource model. These features make it easy for developers to build fast, secure dApps with high accessibility.
A brief history of smart contract
Bitcoin showed the world how distributed ledger technology works and how people can build a financial system based entirely on cryptography.
Although Bitcoin is powerful, it can only do one thing: ledger keeping. To extend this distributed ledger model for more utility, you have to build another blockchain network. Suddenly, you realize you have a network for crypto transfer, another for content creation, yet another for music sharing, and more to come.
This is where Ethereum comes into play as a programmable blockchain platform, which allows you to build and deploy on-chain programs called smart contracts. You can deploy different smart contracts to create cryptos or NFTs, or build DeFi platforms or NFT marketplaces that share the same underlying infrastructure.
What’s wrong with Ethereum’s smart contract programming model
When Ethereum was launched in 2015, people couldn’t actually see what the network would be used for, or what kinds of smart contracts would be built on it.
But, although blockchain’s transparency, decentralization, and tamper resistance make transactions more secure, it’s slower and more costly in data storage than traditional centralized financial systems. Also, despite some tailor-made mechanisms for on-chain data storage, Ethereum’s smart contract language and virtual machine (VM) are mostly based on centralized programming languages. It does not treat the high-value data like digital assets and ownerships any differently than low-value data like a customer’s Zodiac sign.
Since most dApps deal with high-value assets, it incentivizes hackers to look for bugs in blockchain smart contracts. There have been a lot of security incidents that have led to vast amounts of asset losses. Some are intentional attacks, like the DAO’s re-entrancy hack; some are unintentional accidents, like the Parity wallet’s lockdown.
Although you can always blame the developers for being thoughtless, a better way to exterminate such system vulnerabilities is to approach them from the aspects of smart contract language and VM.
How Move’s resource model can help
In the Move language, valuable assets are handled separately as resources. Taking influence from the linear types in Haskell and Rust and the ownership model of Rust, resources in Move are subject to certain restrictions:
- Resources have guaranteed safety because they can never be copied or dropped. They are always passed exactly once.
- Only certain instructions can create or destroy resources, so developers only have to pay more attention on these creation and destruction processes and implement them properly.
- These resources are stored in the user’s storage account.
- Other than higher guarantees of safety, resources can be used in the same way as other native types. They can be stored as data structures and passed as arguments to functions or be returned from functions.
Due to these characteristics, there are quite a few benefits of Move modules, the smart contracts built on the resource model:
- Security: It’s safer to build smart contracts with resources. The common attacks on Ethereum, such as re-entrancy, are practically impossible to happen to assets stored as resources.
- Performance: Since resources are stored in user accounts rather than in a shared smart contract storage like Ethereum’s EVM, it’s much easier to run multiple transactions in parallel. For example, all USDC transfers on Ethereum run on a big balance map on the USDC contract, so all these USDC transfers must run in sequence. In contrast, a USDC transfer on Aptos only operates on the sender and the receiver’s account storages. This makes parallel transactions feasible.
- Fairness: Storing data on the blockchain is costly, because it requires multiple ledger keepers, also called miners, to keep data records. On Aptos, users’ resources are stored in their accounts, making collecting storage rent possible. The more resources users store in their accounts, the more rent they have to pay. This is not only fair in storage fee collection but also gives users incentives to delete useless data.
Moreover, the syntax of Move makes it possible to prove a function does exactly what it’s supposed to do with formal verification, and will never yield unexpected results.
Resource model on Flow
Currently, Flow is the most-used Layer 1 blockchain that adopts a resource model. Its Cadence is a higher-level language easier to write and read but has a very similar resource model to Move’s. Blocto, the largest non-custodial wallet and the builder of the largest DEX and NFT marketplace on Flow, can share first-hand experience writing smart contracts on blockchains with resource models: It’s much easier to write safe and elegant smart contracts on those blockchains with resource models, like Aptos, Flow, and Sui, than on blockchains that don’t, like Ethereum and Polygon.
Blockchains with resource models have many advantages over other blockchains. They can achieve security, performance, and fairness, which are crucial if we want to bring the next billion users onto blockchain.
Aptos is on the right path with its Move language.
- “Introduction to Move” by Diem
- The Move Book
- “The Aptos Vision” by Avery Ching (CTO of Aptos)
- “Resource-Oriented Programming” by Dieter Shirley (CTO of Dapper Labs)
- “Obsidian: A Safer Blockchain Programming Language”
- “Resource-Aware Session Types for Digital Contracts”
- “Fast and Reliable Formal Verification of Smart Contracts with the Move Prover”