NEAR Chain Abstraction Explained

NEAR Chain Abstraction Explained

·

9 min read

Web3 gives users more control over their data and payments. Still, we pay for these benefits with increased technical and UX complexity. In recent years, blockchain ecosystems have tried to improve onboarding to get a hold of the UX part, but as many new chains sprouted, the technical complexities grew with them.

Account abstraction solves key management quite nicely. When a smart contract can decide when TXs are valid, nobody needs to juggle keys anymore, but wouldn’t it be nice if we could abstract away the different chains altogether? NEAR leverages account abstraction, modular data availability, cross-chain liquidity networks, and composable decentralized frontends for chain interoperability—one account for all chains.

This article explains what chain abstraction means in practice and how NEAR achieves it.

What is Chain Abstraction?

Chain abstraction lets you sign and transact on multiple blockchains with one NEAR account. Instead of creating an account for each chain and managing multiple seed phrases or keys, you create one NEAR account and let it take care of the keys and sign for you. NEAR calls the storage of keys for multiple chains in one NEAR account “Account Aggregation”.

NEAR even allows you to hide all blockchain-related information from users. As NEAR supports linking OpenID Connect accounts to NEAR accounts, account abstraction allows using a simple email login to transact on multiple chains simultaneously.

The unique selling point is that no bridge smart contracts are involved; you do all your transactions on the target chain. For example, a DEX that uses chain abstraction could swap Bitcoin to Ethereum directly since the DEX’s keys that manage the funds on their respective chain are all part of a single NEAR account.

Check out our chain abstraction introduction workshop!

How Do NEAR Accounts Work?

Before diving into chain abstraction, you should understand NEAR’s account system, as everything flows from there.

One Account - Many Keys

Each big layer 1 blockchain network has its specialty. NEAR’s killer feature is its account system, which allows you to manage and rotate multiple keys in one account with a human-readable name.

Your account name or “address” could be example.near, so everyone who knows it can send you tokens. However, you could create a key for every smart contract you use to limit the damage if one of these keys gets stolen. As only keys that are currently active in your account can sign new transactions, you can replace one key for one smart contract, keep the keys for all the safe smart contracts, and keep using your account name. Figure 1 illustrates the difference between EVM and NEAR accounts.

Figure 1: EVM and NEAR account comparison

Figure 1: EVM and NEAR account comparison

On EVM chains, you derive an address from a public key, which, in turn, is derived from a private key. Private keys are usually deterministically generated from a seed phrase, so a user doesn’t have to remember all keys.

As EVM chains handle all assets via an address and each address only has one key pair, you can’t rotate these keys easily. A new key pair means a new address and a new address requires moving all assets from the old address to the new one.

NEAR uses account IDs like addresses on EVM chains. NEAR supports implicit accounts, which work similarly to the EVM addresses. Yet, named accounts are where NEAR shines. In the case of named accounts, you don’t derive these IDs from public keys; you store the public keys in the account. Seed phrases are also supported to generate keys. Think of it as ENS built into the protocol.

NEAR handles all assets via an account ID, but since it isn’t directly related to a key pair, you can rotate keys without changing your “address”—no need to move your assets to the new address when you get a new key.

There are two types of keys in a NEAR account:

1. FullAccess Keys

You use them to manage the account by creating and deleting keys, calling smart contract functions, and even deleting the whole account. A FullAccess key gives admin access to an account.

2. FunctionCall Keys

They are light versions of FullAccess keys. A FunctionCall key can call the functions of one smart contract. You can also limit which functions a key can call and set an allowance of funds the key can transfer. If a FunctionCall key gets leaked, you can replace it with a new one.

Support for OpenID Connect and Recovery

Another nice feature (albeit not part of the account system but built on top) is the support for OIDC accounts. With the FastAuth SDK, you can build an email-based authentication flow that creates NEAR accounts in the background and relays transactions via your server. The SDK generates a FullAccess key (controlled by NEAR MPC nodes) to manage and recover the account.

Human-readable account names, key rotation, email logins, and account recovery make NEAR a powerful platform. Consequently, leveraging these features on other blockchain networks would greatly improve the Web3 space.

How Does NEAR Chain Abstraction Work?

Now that you understand NEAR’s account model let’s look at chain abstraction.

As mentioned, chain abstraction lets you sign and transact on multiple chains with one NEAR account. If required, you can even hide all blockchain information from a user.

These are the five features that enable this marvel:

  1. OIDC accounts can control NEAR accounts.

  2. Relay servers can subsidize gas fees.

  3. Accounts on NEAR can hold multiple keys.

  4. Support for MPC key generation functions for other chains (i.e., account aggregation)

  5. A frontend hosting platform that connects the keys on NEAR with libraries that connect to other chain networks.

Since you already learned about the account model and the FastAuth SDK, we will check out points 4 and 5.

MPC Key Generation for Multiple Chains

NEAR allows the storage of multiple keys in one account, but obviously, only the public keys are stored there to enable the network to verify your signatures. The private keys are usually stored locally; you should never upload private keys anywhere!

NEAR wanted to go beyond abstracting multi-chain interactions; they tried to hide all blockchain complexity from users. They created a multi-party computation (MPC) node network for private keys. These nodes use threshold cryptography to hold only parts of each key and can sign messages for the user without one node knowing the full key. This shared custody prevents nodes from using your private key without the consent of multiple other nodes in the network. This feature is called Chain Signatures.

When a user wants to sign a message, each node can use a part of the private key to create a partial signature and send it to the user, who then assembles it into a full signature. You can see the process in Figure 2; each node only has a part of the private key and only generates a part of the signature.

Figure 2: NEAR MPC signing process

Figure 2: NEAR MPC signing process

These MPC nodes got a recent update that allows them to generate keys for EVM chains and Bitcoin, enabling users to sign transactions outside of NEAR.

Layer 2 Data Availability

To verify any proof, you need to see when the transactions happened and be able to reconstruct the state. With NEAR’s Data Availability layer, you can publish your data on decentralized infrastructure for a fraction of the costs on chains like Ethereum or Celestia. See Figure 3 for a cost comparison.

Figure 3: Data availability cost comparison

Figure 3: Data availability cost comparison

Part 3 of our chain abstraction workshop is about data availability.

Frontend Component Hosting

Now that all the pieces are in place, we must connect them. That’s where the Blockchain Operating System (BOS) comes into play. Figure 3 illustrates how the BOS fits into the picture.

Figure 3: The BOS architecture

The BOS platform manages onchain frontend components.

With the BOS Loader, you can fetch built-in components stored on the NEAR chain and reuse them in your application. You can also create your own components and store them on NEAR; there is a handy online IDE to get you started. Each component can access website and blockchain data via the BOS API. A nice extra here: When building a NEAR component, you have components from the Radix library implicitly available, so you don’t have to start from scratch.

NEAR components and the FastAuth SDK form the glue between your users and the blockchain ecosystem. Login with email, let MPC nodes sign transactions for your chain of choice, and then submit them via a relay server.

Part 2 of our chain abstraction workshop series is about building composable and decentralized frontends!

Future Outlook

NEAR has some exciting features in the pipeline that will enable smart contracts to serve even more use cases.

Encrypted Onchain Content

Chain signatures (i.e., signing with MPC nodes) allow anyone to communicate securely with a smart contract by depositing an encrypted payload and then having that content re-encrypted and sent to a third party.

In theory, this can be used for MEV mitigation, assuming we can have encrypted pools of transactions that miners can’t see before they need to be executed. Users send encrypted bids to the chain, and when the bid closes, the network nodes will decrypt the bids and evaluate them synchronously. This enables private Dutch auctions and more efficient trading with less frontrunning or slippage.

Smart Contract Owned Domains

DNSSEC can verify that a smart contract approved everything served from your domain. This gives users the transparency to ensure that a genuine frontend serves the application and the ability to vote on the changes to the frontend rather than just the backend. Everything is versioned.

Omnichain Liquidity

Efficient decentralized economies need efficient and liquid markets so users don’t suffer from random slippage when transacting. Orderly’s decentralized liquidation engine improves the security of derivative trading.

Zero-Knowledge WASM Prover

To push the boundaries of computing beyond blockchains, the NEAR Foundation and Polygon Labs are embarking on a journey to build a zero-knowledge prover for WebAssembly blockchains. This project is still in development.

Chain Signatures Bounty

Do you have an idea for an awesome use of chain signatures?

NEAR offers a 2,000 USDC bounty for the best implementation of chain signatures!

Summary

NEAR wants to be the blockchain operating system, and they are on a good trajectory. With account aggregation, their account model is superior to that of EVM chains, and bringing it to other chains is a boon for the whole blockchain ecosystem. If they can pull chain abstraction off, they could become valuable partners for every DApp creator.

With their onchain component hosting with several built-in components out-of-the-box, they already save developers quite some time, but with FastAuth, MPC key management, and relayers, they could make chain bridging a thing of the past.

Additional Resources

Our chain abstraction workshop series

NEAR Tutorials

NEAR Tools

Other