Developer
Introducing Barz: Trust Wallet’s Smart Contract Wallet Solution
Share post
In Brief
Explore Trust Wallet's Barz, a cutting-edge Smart Contract Wallet using the Diamond Proxy Pattern for modular and secure upgrades.
In February 2024, we successfully launched Trust Wallet SWIFT, an account abstraction wallet to give our users a more secure, smarter wallet. Trust Wallet SWIFT introduced innovative features including passkeys, gas payment with 200+ tokens, 1 step swap & bridging. Trust Wallet SWIFT was also the first time we utilised our Smart Wallet solution “Barz”. Today, this solution is now open source!
Let’s dive into the details of how we got here!
Why we built Barz
Trust Wallet, empowers more than 122 million Web3 users worldwide and understands the common issues and inconveniences users face when using wallets.
Many users struggle with:
Improper management of their mnemonic phrases
Granting excessive privileges to a dApp for a single transaction
Ability to create multiple automated tasks, e.g. schedule payments
While the issues and challenges with mnemonic seed phrases are well known, there are larger security and UX issues as more users are onboarded to Web3.
To provide a solution to these challenges and limitations and ultimately drive more adoption of Web3, we decided to develop a Smart Wallet through Account Abstraction, which offers a fundamental solution overcoming these limitations - Barz.
Barz
Barz is an ERC 4337 compatible Smart Contract Wallet focused on a secure and smarter experience for users through modular, upgradeable, and secure designs.
We aggregated the benefits from each wallet and pioneered new approaches to provide best-in-class service to users. Barz is also one of the first passkey-based 4337 account that’s launched in production.
Barz, at its core is a proxy contract that utilizes the Diamond Proxy Pattern(EIP 2535) for a scalable and secure addition of use cases with high security threshold.
Barz system currently has 12 fully built Facet implementations that can provide features of:
Account Recovery
Lock
Signature Migration
Guardian
Restrictions (Custom Rules for Transactions)
Diverse Validation Mechanisms
Secp256k1 - Default EVM Scheme (e.g., Mnemonic phrase)
Secp256r1 - Passkeys, Okta
Multi-sig
Let’s dive into Diamond Proxy pattern and how it works with ERC 4337. We’ll go further into the optimization points we made to Diamond for Barz in our next article.
Diamond
Diamond is a modular smart contract system enabled by a multi-faceted proxy stated in EIP-2535.
A multi-faceted proxy is different from the conventional proxy pattern like UUPS(Universal Upgradeable Proxy Standard) and TransparentUpgradeable where they have a single implementation to route the call to.
For example, a UUPS based proxy smart contract stores the single implementation contract address in the EIP-1967 based storage slot and performs upgrade by modifying the storage slot.
Diamond Proxy on the other hand provides a flexible management of Implementation and higher modularity.
Upon this system, Barz has made many innovative changes to the Diamond pattern itself for a higher security threshold and smarter wallet experience.
In addition, Barz will soon unveil the industry’s first multi-tier module system that provides maximum modularity and foster a secure open environment for interoperability and scalable addition of use cases.
For a more detailed explanation of Barz, check the full article here in our here developer.trustwallet.com.
Conclusion
The Barz Smart Wallet Architecture utilizing Diamond allows modular and flexible development of a wide array of use cases. It allows each Facet to focus on its specific business logic while providing the flexibility to easily switch each component and maintain interoperability.
This is the first of an article series on Barz. The four-article series will cover:
Introducing Barz: Trust Wallet’s Smart Wallet Solution
Cutting Diamonds: How to make Accounts Awesome????
For Builders By Builders: Introducing the Barz SDK
Multi-tier Module system: A secure foundation for open innovation
In our next article, we’ll share the optimizations we did to make Diamond much better for building smart wallets. Stay tuned for our upcoming articles and releases of powerful use cases of smart wallet built on Barz.
If you have questions or want to use Trust Wallet’s AA SDK in your service or have any ideas for collaboration, please reach out in the smartwallet channel in our Trust Wallet Discord.