Context
Account abstraction has been gaining significant attention lately, and for good reason - it has the potential to simplify user experience and drive crypto adoption. If you’re still wondering what all the fuss is about, check out “WTF is Account Abstraction” before reading on.
With the launch of zkSync Era which introduces native support for smart accounts, it's crucial for developers to ensure their applications are compatible with smart accounts.
Why native smart account support matters
Without native smart account support (i.e. at the protocol level) it is difficult to implement full account abstraction and reap its benefits to improve user experience and drive wide adoption.
Layer 1 Ethereum and EVM chains do not natively support smart accounts and although contract accounts are the only accounts that can implement arbitrary logic, EOAs are the only type of account that can initiate transactions on these chains.
However, smart accounts in zkSync Era can initiate transactions, like an EOA, but can also have arbitrary logic implemented in them, like a smart contract.
Smart account wallets such as Argent provide their users with a seamless, secure, and efficient experience. However, in order to tap into that user base, dapps must ensure their compatibility with smart accounts.
The good news is that integrating smart accounts is straightforward; there are just two conditions to check. So let's dive in!
How to make your dapp compatible
Being smart account compatible is pretty light. In fact, you might already be compatible without knowing!
1. Use EIP-1271 signature validation in your smart contracts (Solidity) and front-end (JavaScript), instead of using ecrecover directly.
To validate signatures from smart contracts, we recommend using OpenZeppelin's SignatureChecker:
To validate signatures from the front-end, we recommend using Matter Labs' library to abstract the logic away:
2. Avoid using tx.origin which poses a security threat and will trigger a transaction failure with smart accounts.
That’s it! You are now smart account compatible! 🎉
What now ?
Now that you are compatible with smart accounts, you can fully leverage the power of account abstraction on zkSync Era and 10x your User Experience !
Here are a few things to get you started:
Implement Argent Login and tap into the most active zkSync community
With more than 350,000 users on zkSync Era waitlist, Argent mobile wallet is the gateway to the zkSync ecosystem. With Argent Login, you can ensure the best interaction between your dapp and Argent’s wallet.
Leverage account abstraction through multicall and improve UX of your dapp
Using a dapp on Ethereum today requires approving a new transaction for every on-chain interaction, which can be a frustrating, time-consuming, and expensive process, particularly when gas fees are high.
Smart accounts have the ability to group multiple transactions together and execute them at once, greatly improving the user experience of dapps (for example, when you have to send 2 transactions for approve + swap on a DEX).
Argent has a SDK that bundles a multi-transaction flow into a single transaction if the user is connected with a compatible account like Argent, and gracefully degrades to sending multiple transactions if multicall is not supported.
Use a paymaster to subsidise your users’ transactions
A paymaster is a smart contract that can subsidise transactions for users, hence abstracting gas fees away. Dapps can use Paymasters to subsidise fees, allow users to pay fees with non-native tokens (e.g. a protocol’s own governance token) or sponsor specific transactions.
Refer to Matter Labs documentation to understand how to implement Paymasters in your transaction flows.
Session Keys
Session keys represent a significant UX breakthrough as they enable users to pre-approve the rules governing their interactions with a dapp, allowing them to engage with the platform without requiring a signature for each transaction.
By utilising session keys, users can streamline their interactions with dapps, enjoying a seamless experience without sacrificing security. Ultimately, this breakthrough will contribute to greater adoption of dapps, as more users will be able to interact with them in a safe, efficient manner.
If you want to implement sessions keys in your dapp, please reach out to Argent at dapps@argent.xyz
Workshop with Argent & zkSync
Need a step-by-step guide to make your dapp smart account compatible ? Have a look at this tutorial.