Developers Journal: Implementing Account Abstraction

In the dynamic world of blockchain technology, the revolution of Account Abstraction (AA) has significantly shaped the Ethereum ecosystem, simplifying the digital wallet experience by merging the functionalities of external owned accounts (EOAs) and smart contracts. This integration paves the way for a more intuitive user experience, steering clear of the conventional complexities tied to blockchain interactions.

Delving into the technical backbone of AA, ERC-4337 emerges as a pivotal element in this narrative. Championed by the Ethereum community, this proposal has been instrumental in enabling seamless interactions within the Ethereum network devoid of the conventional hurdles of private key management and the intricate understanding of gas fees. ERC-4337 entrusts these critical responsibilities to smart contract wallets, thereby abstracting the intricate technicalities from our users.

A cornerstone of AA, propelled by the mechanisms of ERC-4337, is the simplification of the transaction signing process. In contrast to the traditional reliance on private keys for EOAs, which is often viewed as both cumbersome and susceptible to security vulnerabilities, AA leverages smart contracts for authentication. This shift not only fortifies security but also introduces an unprecedented level of flexibility in transaction execution, allowing for the implementation of complex rules such as multi-signature requirements and spending limits.

Moreover, ERC-4337 heralds the advent of ‘Bundlers‘ within the ecosystem. These unique entities, akin to specialized nodes, diligently monitor a bespoke mempool of user operations, amalgamating operations from diverse senders into a singular transaction for blockchain execution. This innovative architecture democratizes the transaction inclusion process, paving the way for novel transaction fee models and enhancing the scalability of blockchain applications.

A Closer Look at Rivo’s Wallet Offering

At Rivo, we’ve passionately crafted a multi-chain smart-contract wallet combined with a DeFi marketplace. Our platform seeks to make DeFi interactions as straightforward and secure as possible, primarily via our innovative account abstraction (AA) wallet solution.

Our journey toward integrating AA into Rivo’s wallet infrastructure was driven by our desire to create seamless digital experiences across various blockchains. To achieve this, we’ve embraced a ‘Web3Auth’ technology, ensuring that creating a wallet is as easy and familiar as logging in with Gmail, X, or Discord. This not only upholds our users’ privacy but also bridges their social media presence with their web3 identity in a secure manner, all the while discarding the conventional need for a seed phrase. It’s a leap towards making blockchain accessible to newcomers, removing barriers that might deter their entry into the market.

But our ambitions didn’t stop at accessibility. We’ve ventured further to empower our users with unparalleled flexibility in managing their transactions. A standout feature we’re particularly proud of is the ability to pay gas fees with any token a user chooses. This breakthrough was made feasible through the innovative concept of ‘paymasters,’ introduced in Ethereum Improvement Proposal (EIP) 4337.

Paymasters are essentially smart contracts that enable flexible gas policies, allowing for transactions to be settled with any ERC-20 token. This level of flexibility is unprecedented in the traditional Ethereum ecosystem and underscores our commitment to not just meeting but exceeding our users’ expectations.

Rivo’s journey toward implementing an AA-centric storage solution was marked by a series of intricate challenges, each necessitating its own innovative solution. A core challenge stemmed from ERC-4337’s design structure, which transfers different account properties (like gas payment and authentication) into smart contracts.

The shift increased the potential for security vulnerabilities, a notable example being the compatibility issues with Lido’s token bridge. This problem highlighted the need for us to engage in collaborative problem-solving, leading us to work alongside Lido to develop the necessary workarounds to ensure seamless functionality.

Another significant hurdle was the transition in transaction handling from external owned accounts (EOAs) to UserOperations under AA. This change complicated the debugging process, especially since most transactions within the Rivo ecosystem involved swaps with multiple contracts. Our response during their beta phase was to deepen our expertise in debugging — achieved by collaborating with the ZeroDev team to refine our approach.

In this regard, the adoption of tools like the UserOp debug tool, along with Tenderly and Stackup debugger, became crucial in managing these complex transactions. An added challenge was the inability of external providers to track AA transaction history accurately, prompting us to develop a system for tracking and parsing transaction events directly from their wallet offering.

Gas fees posed a significant challenge, with AA transaction fees being notably higher than those for traditional External Owned Accounts (EOAs). This discrepancy was attributed to several key factors. Firstly, we found smart contract transactions to inherently involve more complex contract interactions compared to simple EOA transactions. For example, a straightforward operation like sending ETH in an EOA setup merely adjusts a single balance value.

In contrast, AA transactions — facilitated through smart contracts — necessitate processing more data and executing multiple contract interactions, thereby consuming more gas. The performance of bundlers, too was found to be insufficient oftentimes, further exacerbating the issue. Another contributing factor was the comparative cost of gas fees on Ethereum, which are inherently higher than those on Layer 2 (L2) solutions.

A specific issue arose with Layer 2 (L2) + Rollup integration related to preVerificationGas (PVG), which led to disproportionate AA transaction fees. The complexity of L2 gas pricing plays a crucial role in this challenge, as it is determined by two main components: the L1 data cost and the L2 execution cost. During the estimation process, bundlers collect the most recent L1 data cost and incorporate it into the PVG.

However, there are instances where, after a user has initiated the UserOp, the L1 callData cost experiences a significant decrease, yet the PVG remains fixed at its initially higher value. This mismatch is a primary reason why AA transaction fees can end up being 10 times higher than anticipated. Despite the Rivo development team’s proactive discussions with bundler providers and their active participation in AA Core Dev calls, a significant portion of the resolution continues to hinge on external development efforts, particularly those being undertaken by the Optimism team.

In response to the gas fee challenge, our team adopted multiple strategies to mitigate costs. These were primarily focused on selecting networks like Polygon, known for lower gas fees, and optimizing transactions by combining approvals and swaps into single operations. Rivo also utilized accurate gas price estimators

The Future of Digital Wallets

The implementation of AA tech into Rivo wallet design marks a significant advancement for the blockchain and DeFi ecosystem. This is because AA wallets are known for their enhanced user experience and ability to remove the complexities traditionally associated with blockchain transactions, such as the management of private keys.  Moreover, the integration of smart contracts into our wallet operations adds a layer of security and flexibility, enabling users to define specific rules for transactions.

Looking ahead, we are poised to introduce a social recovery function into Rivo wallet, thereby adding an extra layer of security and allowing our users to recover their accounts through trusted contacts. It’s a feature that addresses one of the major concerns in digital asset management — i.e. the risk of losing access to one’s wallet.

This article is the first in a series from Rivo’s developer journal, where we aim to share our journey in the ever-evolving blockchain landscape. Future entries will delve deeper into our development process, the challenges we have faced/continue to face as well as some practical tips we’ve gathered along the way. Our goal with the series will be to not only advance our platform but also contribute to the broader blockchain community by sharing our learnings and insights.