Blockchain has the potential to revolutionize the way we interact with the digital world. It promises security, transparency, and decentralization. However, for most people, getting started with blockchain can be confusing and intimidating. The need to manage private keys and wallets can be a significant hurdle.
To make blockchain more accessible, developers have been exploring ways to simplify the process, and one exciting concept is abstraction. In this article, we’ll look at what abstraction is and how it creates a better web3 wallet experience. Later, we’ll take a detailed look at how it is implemented on Flow, a blockchain-focused on mainstream web3 adoption and used by companies such as the NBA, NFT, Ticketmaster, and Mattel.
In the realm of computer science and software development, abstraction is a fundamental concept. Abstraction simplifies a system by removing certain characteristics to reduce complexity and enhance efficiency. For most blockchain users, dealing with private keys and wallets can be intimidating and inconvenient. Abstraction in blockchain aims to address this issue. There are two primary ways to manage keys and assets in the blockchain: user custody and application custody.
This is considered the safest and most ideal version of blockchain management. With user custody, you hold your own keys on a device like your computer or phone. A special software called a "wallet" helps manage access to your keys. When you use a blockchain application, it asks your wallet for permission to do things like send money, and you get to approve or deny these requests. User custody gives you full control and security over your assets.
On the other hand, application custody is an approach in blockchain where the responsibility of managing private keys and wallet software is shifted from the user to the application or service provider.
Let’s see how it works and why it's valuable:
Application custody isn’t just convenient; it also prioritizes a user-friendly onboarding experience by handling key management and wallet complexities on behalf of the user.
However, it limits the portability of assets outside of the application, which is where the concept of account abstraction (specifically account delegation) comes into play. Abstraction bridges the portability gap and offers users more control and flexibility over their blockchain assets.
To solve this issue and to create a balance between user custody and application custody, developers are turning to something called "account abstraction," specifically, "account delegation." Account delegation refers to a dynamic in which any account that has a valid capability to another account object in the storage can access it. This feature allows one blockchain account to delegate control to another. The account that delegates (the "child" account) still uses cryptographic keys, but the owner of the other account (the "parent" account) gains access to its assets. Importantly, the child account must give permission for this access, and it can take it back at any time. This connection between accounts forms a hybrid custody model that combines the benefits of both user and application custody.
Here's how it works in simple terms:
Before moving forward, it's important to understand the concept of account linking, a unique Flow concept that enables the sharing of ownership over accounts. Cadence (the smart contract programming language for Flow) provides two ways to access Flow accounts:
With Cadence, you can create permissions to share access to account storage. This means if an account has valid permission to access another account's storage, it can get in. You can also control what parts of the storage can be accessed with these permissions.
Account linking is doable by adding these permissions to the AuthAccount object. Just like storage permissions allow access to data stored in an account, AuthAccount permissions enable access to the AuthAccount itself.
When we talk about "account linking," it's like a parent account sharing a special access card (AuthAccount capability) with another account, making it their child account. This happens in two simple steps on Flow:
transaction {
prepare(signer: AuthAccount) {
let capability = signer.linkAccount(/private/accountCapA)!
signer.inbox.publish(capability, name: "accountCapA", recipient: 0x1)
}
}
transaction {
prepare(signer: AuthAccount) {
Let capability = signer.inbox.claim<&AuthAccount>("accountCapB", provider: 0x2)!
let accountRef = capability.borrow()!
}}
Account linking was created to help users easily join your Flow-based app without needing a wallet first. This makes it simple for everyone to use Flow apps without technical issues or the need to install a wallet. You can enjoy apps right away and also have the option to own your data later on.
With account linking, users can connect multiple app accounts together. You don't need to worry about the complexities of accessing these accounts because it's all managed through one main account.
The best part? Assets can move freely between these accounts without any extra transactions. Your app account can now interact with the broader Flow ecosystem seamlessly.
With this feature, users can have full control over their digital items in their in-app account. This means they truly own these items, not just within the app but also outside it. They can easily view their inventory using their parent account and even use these items in other apps, like a marketplace or a game. The best part is they can do all this without the hassle of transferring items between accounts, making it super convenient to use multiple apps at once.
Blockchain development is evolving to make it easier for everyone to get involved. Abstraction, through account delegation, is a key part of this evolution. It combines the safety of user custody and the convenience of application custody, allowing users to transition smoothly from beginners to experts in the blockchain world. As blockchain technology continues to grow, these innovative ideas will help make it more accessible to everyone.
Have a really great day!
Also published here.