NEAR
Unlocking Web3 Usability with Account Aggregation – NEAR Protocol

Unlocking Web3 Usability with Account Aggregation

Developers
February 15, 2024

Since the start, the focus for the NEAR ecosystem has been on advancing Chain Abstraction, or hiding the elements of the blockchain (“abstracting away”) from users so they are not barriers to entry or participation in the decentralized Web. In Web3, the data and assets belong to the user, tied to their on-chain, noncustodial account. Currently every user has separate (usually many) accounts on each blockchain and also needs separate wallet software to manage those accounts. This requires users to manage the security for each account and wallet individually, deal with complex recovery processes if they make a mistake, and go through a thorny series of manual steps to move any assets into their wallets or across different wallets and chains. 

The current world, where every wallet is managing accounts on many chains, is untenable as each account slowly falls out of sync with the others. In order to provide a consistent, abstracted experience for users across all chains, we need to aggregate accounts across all chains within a single interface––account abstraction alone is not enough. Enter Account Aggregation.

Account Aggregation––the ability to transact on any blockchain through a single account and interface––is a critical pillar of advancing Chain Abstraction, defragmenting Web3 for app users and increasing their ability to move across networks or between applications with ease. Developers should not be building apps on single chains anymore in order to reach some specific market or pool of liquidity. Now dApps can truly become decentralized applications, yet still feel like the unified experience of using an app. 

To enable an effective user experience for using all blockchains, without users needing to think about underlying infrastructure or switch networks, it’s important to have a single account from which they can navigate all of Web3. This means no manual bridging, no managing long lists of addresses on different networks, no gas tokens, and no more switching between wallets and networks. In the true spirit of Web3, this single account should be non-custodial and non-dependent on a specific wallet software or any other single service provider. 

NEAR is enabling such an experience for all Web3 users with Account Aggregation, which consists of 3 core technologies. 

  • NEAR Account: account abstraction for smooth onboarding and recovery of accounts.
  • Chain Signatures: enabling NEAR network to have MPC nodes that are jointly signing transactions and messages.
  • Intent Relayers: parties in the ecosystem that are able to execute the intent of the user on different chains.

By adding Chain Signatures and Intent Relayers to the already robust NEAR account model, NEAR can become the home for multichain apps that abstract the pain points of switching networks and managing gas fees, bridging, and long lists of accounts away from end users. 

This post details the 3 technical pillars of Account Aggregation and how they combine to deliver the next generation of usability for any decentralized application. Chain Signatures and Intent Relayers will be available on NEAR testnet by early March 2024. 

NEAR Account

Account aggregation on NEAR begins with the innovative NEAR account model. Incorporating native account abstraction since launch, NEAR’s account model offers a high degree of flexibility to developers and users alike. Ethereum introduced its version of account abstraction, EIP-4337, in March 2023. 

Native account abstraction means that a given NEAR account maps to a human-readable account name instead of a public key hash, so accounts can have a large number of keys with different permissions for different functions. This means that NEAR account security is both stronger and easier to manage for users, while also allowing much broader functionality within a single account.

FastAuth, the industry-leading account creation experience NEAR launched in 2023, offers a Web2-like onboarding flow: users can sign up with just an email, and they don’t need to save a seed phrase or password. Instead, their FastAuth account and keys are secured using “Passkeys,” a new technology that replaces passwords with biometrics such as fingerprints or FaceID linked to a device. Users can also recover access to their account at any time by using their email through the MPC recovery service.

Now, with added multichain functionality on the horizon, the power of the NEAR account can extend across all of Web3 and offer easier onboarding and security management to users of any decentralized application. By having passkey integration, revocation, and recovery in one place rather than scattered across every chain, users will have a significantly streamlined experience for managing their Web3 accounts.

Chain Signatures

Chain signatures allow any NEAR account to have associated “remote” addresses on other chains and to sign transactions and messages from those addresses. 

Traditionally a user would have different private keys in different wallet providers to facilitate multichain interactions and would need to manage them manually. With Chain Signatures, the NEAR MPC network is the signer for these remote addresses, meaning there is no explicit private key.

MPC (multi-party computation) signing allows a number of independent nodes to sign a message with key shares separately generated by non-trusting parties without needing to assemble them anywhere. The challenge with the standard MPC signing approach is that if nodes are changed, a new public key needs to be generated. The introduction of a novel threshold signature protocol which has a procedure of key resharing allows the MPC signer to maintain the same aggregate public key even as key shares and nodes constantly change.

Chain Signatures is the NEAR approach to make this model programmable. Making MPC signer nodes that are also nodes in the NEAR network allows for a smart contract call to instantiate a signature procedure for a given account. By using different derivations constructed from a chain ID, a NEAR account ID, and a provided path, each account receives an infinite number of remote addresses on every chain. 

This amplifies the power and flexibility of NEAR accounts by allowing them to operate on any chain. Any NEAR smart contract can sign transactions and messages targeted for other chains––introducing another novel account programming primitive and extending the NEAR account model across all of Web3.

The MPC signer network will start as a subset of validators and partners of NEAR. Over time it is expected to be added to all NEAR validators on the protocol level to continue increasing the security of the system. 

Intent Relayers

We can’t expect app users to pay gas fees in various native tokens across different chains. We also should not require users to explicitly swap tokens on the destination chain in order to pay there. To achieve a smooth user experience, it should be easy for users to pay on the NEAR network and then be able to transact value on other chains, i.e. to relay their intent from NEAR to another chain.

With intent, a user can state what they want to achieve and leave out how it should be done. Users should be able to specify any action they want to take without having to navigate or understand the intricate complexities of multiple transactions on multiple chains they will be executed on, nor the swaps and funding required to achieve that action. 

Although Chain Signatures is a generic technology that can be used in many ways for the first iteration of Account Aggregation, the relayer smart contract will control the remote account for users. This means that instead of the user’s account mapping to an address, the relayer.near will have a derivation for each user, allowing this smart contract to initiate signing and offer other services (like trading derivations).

Let’s look at an example of how the first iteration of intent relayer will abstract away cross-chain gas and payments for a NEAR user: 

  • User has a root.near account that maps to the remote Ethereum address 0xabc via the relayer’s smart contract.
  • User initiates a transaction to buy a BAYC NFT on OpenSea using their NEAR account and pays in $NEAR by doing a transaction on the NEAR network to relayer smart contract with Ethereum transaction payload in arguments and attaching the required $NEAR amount.
  • The relayer smart contract will then forward the transaction bundle to the NEAR MPC signature contract. This bundle consists of (1) the transaction to fund the user’s 0xabc with $ETH required for gas and NFT payment and (2) user’s transaction to buy the BAYC NFT on OpenSea.
  • The Chain Signature contract will sign both transactions using different derivations respective to the relayer contract and originating user.
  • The relayer operator will observe the response from MPC service with signed transactions and submit them to the Ethereum network. This starts with initiating a fund transfer from a treasury paymaster account on Ethereum. This paymaster account will transfer ETH to the user’s 0xabc Ethereum address, equivalent to the NEAR that was originally sent by the user. 
  • Then the relayer will submit the final transaction and the BAYC NFT will be purchased from the user’s 0xabc address using ETH to cover gas and payment.

The above example showcases how an intent relayer reduces complexity for a user to complete a cross-chain transaction. This is an intent-based architecture, and this is only a brief initial example of what will be possible in the future to provide a seamless user experience and abstract blockchains for users.

The intent relayers approach allows users to pay with any assets they own, not just $NEAR, opening up wallet and application developers to offer a variety of options: using application tokens for paying for multichain transactions, offering a subscription model by charging a flat fee, or offering extra discounts to incentivize specific behaviors. 

Use Cases

One account for using apps on all chains unlocks a range of previously difficult use cases for founders and developers. Here are some examples for founders and developers to consider as the possibilities for excellent multichain user experiences expand with Account Aggregation.

Expanding user base for existing applications. Currently applications are only targeting the user base of the single chain they have launched on. With Account Aggregation, users can log into applications from every chain as an alternative wallet option. Application developers will simply need to add “Connect with NEAR” to their wallet selector.

Wallet developers can also leverage NEAR’s decentralized and composable interfaces together with Account Aggregation to surface applications across all chains directly within their wallet experience.

Bridgeless DeFi. The first example is bridgeless, cross-chain DeFi where a NEAR account can be a gateway to multiple chains through a unified app experience. This is especially useful for apps like DapDap, built on NEAR, which lets users discover DeFi apps and experiences from a range of L2s and start using them within a single interface. 

Multichain DEX. One of the most desired but also complex-to-build use cases is a decentralized exchange (DEX) that works across most if not all chains. Currently users must default to centralized exchanges for such a multichain experience due to the complexity of bridging, gas, and handling separate wallets. With Account Aggregation, DEX smart contracts can live on NEAR while having deposit addresses across all chains. This means there is no need to bridge assets to a single chain to swap or for the user to bridge to the chain where assets have liquidity. Instead they can easily swap $BTC on the Bitcoin network for $OP on Optimism using such a NEAR smart contract.

Bridging Assets. Although the Account Aggregation approach really focuses on using canonical assets on where they are issued, sometimes there is value in having wrapped assets. For example, in cases like Bitcoin or Ethereum where the canonical assets are too expensive and slow to move, wrapping becomes quite useful. To build a specific token bridge using Account Aggregation is just to make a NEAR smart contract that keeps an account of deposits of a given token and issues that respective token balance.

Trading multichain asset bundles. Beyond simple trading, Account Aggregation allows users to make a NEAR account into a bundle of multichain assets. NEAR accounts themselves are tradeable (see NEAR account marketplace NameSky), which also allows the trading of everything that is deposited to such an account across all chains. For example, say the account xyz.near has 2 BTC, some BRC-20, a BAYC NFT on Ethereum, and some veCRV. By trading this entire account, there is no need to move each of the underlying assets on the other chains.  Instead, the new owner comes into possession of the whole bundle when the keys are rotated to them on the account.

There is also an interesting potential approach to implement a multichain exchange of assets via a smart contract that internally maintains a mapping from an owner account to a given path derivation (which is what determines remote addresses on other chains). One can trade the derivation paths inside this smart contract, trading everything deposited on a remote account without trading the entire account. For example:

  • Smart contract dex.near internally maintains: 
  • derivation=/0/0/1 → root.near
  • derivation=/0/0/2 → alice.near which maps to 0xabc on Ethereum
  • alice.near can sell root.near the derivation inside this smart contract for some amount on NEAR and now it will be inside dex.near. Then root.near can request to draw Ethereum assets from it later. 
  • derivation=/0/0/1 → root.near
  • derivation=/0/0/2 → root.near

This approach means users can trade assets across all chains at the speed (1s block time) and cost (below $0.01) of using NEAR.

Delegated Smart Contract Permissions on NEAR. Another use case for Chain Signatures is the ability for a NEAR smart contract to execute something on behalf of other users––for example, to recover keys for an app user. 

Let’s say there is a social_recovery.near contract that keeps track of a mapping of friends for a given account root.near. This root.near account at some point added a public key that the social_recovery.near account can sign via Chain Signatures. Friends can initiate a recovery flow, where they send a new public key given to them by the user to social_recovery.near. If enough friends do this, the social_recovery.near requests to sign a NEAR transaction that adds a new key on behalf of its own remote key with signer root.near. When executed, this transaction adds a new key to root.near, allowing the user to recover their account via a social recovery process they can set up in case they need it. 

Similarly, smart contracts can execute rebalancing of pools on behalf of the user based on some condition and any other logic that the user decides to “install” on their account by adding a remote key from that account.

DeFi on Bitcoin (and other non-smart contract chains). Using chain signatures, smart contracts on NEAR can control externally-owned accounts on non-smart contract chains like Bitcoin, Dogecoin, Ripple, Bittensor, Cosmos Hub, etc. This enables developers to use NEAR as a smart contract “layer” for chains that do not support this functionality natively. 

For example, a developer can build a decentralized exchange for Bitcoin Ordinals, using a smart contract on NEAR to manage deposits (into Bitcoin addresses controlled by the contract) and to verify and execute swaps when two users agree to trade BTC for an Ordinal or BRC20 token. 

Coming Soon to NEAR Testnet

Excited to build with Account Aggregation? Keep an eye on NEAR’s docs: Chain Signatures and Intent Relayers are expected to be available on testnet by March 1, 2024. And join members of the NEAR ecosystem at the Chain Abstraction Summit, co-sponsored by NEAR Foundation during ETHDenver, to learn more about Account Aggregation and exciting innovations from all the projects contributing to Chain Abstraction.

–Illia Polosukhin, David Millar-Durrant, Gautham Ravi, Dio Ortega, Mally Anderson


Share this:

Join the community:

Follow NEAR:

More posts

A Post from Illia Polosukhin
May 22, 2024

User-Owned AI is NEAR

We use our own and third-party cookies on our website to enhance your experience, analyze traffic, and for marketing. For more information see our Cookie Policy.