paint-brush
Simplifying Blockchain: How Abstraction is Revolutionizing the Web3 Wallet Experience on Flowby@johnjvester
6,392 reads
6,392 reads

Simplifying Blockchain: How Abstraction is Revolutionizing the Web3 Wallet Experience on Flow

by John VesterOctober 5th, 2023
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Finally, the concept of abstraction is finding a place in web3 and should help make blockchain development less confusing and intimidating.
featured image - Simplifying Blockchain: How Abstraction is Revolutionizing the Web3 Wallet Experience on Flow
John Vester HackerNoon profile picture


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.

What is abstraction?

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.

User 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.

Application Custody

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:


  1. User-Friendly Onboarding: With application custody, the user onboarding process is designed to be extremely user-friendly, similar to how people sign up for traditional online services. Users are not required to install any wallet software or deal with the complexities of managing private keys. They can create an account with the blockchain application just as they would with any other web2 service, using a username and password or other familiar credentials like their Google or Facebook login.
  2. No Wallet Management: In an application custody model, users don't have to worry about onerous wallet management, such as securely storing private keys or making backups. This simplification is especially attractive to users who are new to blockchain technology and may find the concept of wallets and private keys confusing.
  3. Traditional Payment Methods: Application custody also enables blockchain applications to accept traditional payment methods, such as credit cards for web-based applications or native in-app purchases for mobile apps. This means that users can pay for blockchain-based services using methods they are already familiar with, making the payment process seamless and comfortable.
  4. Reduced User Consent: Another advantage of application custody is that applications can manage the assets within the user's account directly, all without needing to request user consent for every action. For example, if a user purchases an item within a mobile game using in-app purchases, they don't have to repeatedly approve each transaction through their wallet. This streamlines the consent process and feels more like the traditional web2 user experience.

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.

The Solution - Connecting both worlds with abstraction

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.

How it works

Here's how it works in simple terms:


  • Easy Start: New users, who might find the idea of managing keys intimidating, can sign up for an account without dealing with wallets. It's similar to signing up for any other online service.
  • Growing Confidence: As users become more familiar with blockchain and gain confidence in managing their keys, they can delegate control of their app-custody account to their self-custody account.
  • Full Control: With their own keys on their own devices, users can access all their assets in both accounts. They keep control while still letting the application manage assets in the child account, reducing the need for constant interactions with wallets.
  • Interoperability: Because this delegation relationship is tracked on the blockchain, the application can recognize it and access the assets in the parent account when necessary. This makes it easy for users to move assets between accounts for seamless access.

Deep dive into walletless building

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:


  • PublicAccount: This gives you access to public account info like address, balance, and storage, but you can't make changes.
  • AuthAccount: With AuthAccount, you get the same access plus the ability to make changes, like adding/removing keys and managing contracts.


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:


  • The child account creates and shares the AuthAccount capability with the parent account. Implementation in code: Create Capability


transaction {
    prepare(signer: AuthAccount) {
        let capability = signer.linkAccount(/private/accountCapA)!
        signer.inbox.publish(capability, name: "accountCapA", recipient: 0x1)
    }
}


  • The parent account can then use this capability to access the child's account easily.
    Implementation in code: Claim Capability


transaction {
    prepare(signer: AuthAccount) {
Let capability = signer.inbox.claim<&AuthAccount>("accountCapB", provider: 0x2)!
        let accountRef = capability.borrow()!
    }}


Why is account linking useful?

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.

Conclusion

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.