Understanding ERC-6551: Non-fungible Token Bound Accounts
Token-standard for smart contract accounts owned by ERC-721 NFT tokens.
NFTs have completely revolutionized the space after introducing the ERC-721 standard, paving the way for endless innovative use cases. NFTs are unique and valuable tokens that cannot be exchanged for anything else. With this functionality, these tokens are non-fungible and allow artists and creators to sell unique art pieces, collectibles, and even virtual real estate.
The Current Limitation with ERC-721
ERC-721 contracts are useful as on-chain identities, but they have some big drawbacks and limitations:
They are not able to interact with other on-chain assets or contracts. This limits their usefulness compared to other forms of on-chain identities that can interact more effectively.
The unchangeable JSON metadata of ERC-721 tokens is another limitation that cannot be adapted, which can pose some issues when it comes to handling a significant number of Uniform Resource Identifier (URI) codes, enhancing security, and increasing efficiency. This inflexibility signifies that no extra information or value can be incorporated into the token.
Previous efforts to enhance NFT tokens with asset-ownership capabilities have mostly involved creating a complement to the ERC-721 standard. This approach necessitates the inclusion of proposal support in individual token contracts, leading to incompatibility with previously deployed ERC-721 contracts.
And surprise! - here is when ERC-6551 comes to be the solution to overcome these current limitations of by providing them with the complete functionality of smart contract wallets in every ERC-721 token, all while guaranteeing that they are still backward compatible.
TL;DR: What is ERC-6551?
ERC-6551 in brief, is the Ethereum Standard for token bound accounts. These accounts are owned by a single ERC-721 token, with the capability to interact with the blockchain, record transaction history, and even own on-chain assets.
In a cool twist, control over each token bound account is delegated to the owner of the ERC-721 token. This means the owner can initiate on-chain actions on behalf of their token, offering a new level of dynamism and interactivity.
Token Bound Accounts are designed to work seamlessly with a wide range of Ethereum accounts and infrastructure. This allows the creation of a smart contract wallet for every NFT - Whether you're using on-chain protocols or off-chain indexers, you can count on the compatibility of token bound accounts. By bridging the gap between on-chain identities and on-chain asset ownership, ERC-6551 has the potential to unlock a new paradigm in the current space.
How does it work?
The architecture is based on two important components:
A permissionless directory for deploying token bound accounts
A standard interface for implementing token bound implementations
Registry
The registry acts as a singular access point, and it provides two key functions:
createAccount
- Deploy a token bound account for an ERC-721 token using a given implementation address.
account
- A read-only function that calculates the token bound account address for an ERC-721 token using a specific implementation address.
The registry deploys each token bound account as an ERC-1167 minimal proxy with unalterable constant data appended to the bytecode.
(You can find this illustration of the relationship between ERC-721 tokens, ERC-721 token owners, token bound accounts and registry in EIP-6551)
The architecture of each token bound account, once deployed, should look like this:
ERC-1167 Header (10 bytes)
Implementation Address (20 bytes)
ERC-1167 Footer (15 bytes)
Salt (uint256 - 32 bytes)
ChainId (uint256 - 32 bytes)
TokenContract Address (32 bytes)
TokenId (uint256 - 32 bytes)
Token-bound account proxies are designed to redirect the execution towards contracts that follow the IERC6551Account interface. Additionally, the registry leverages the create2 opcode to deploy all token-bound account contracts. This allows the account address for every ERC-721 token to be determined predictably.
ERC-6551 Main Use-Cases:
Membership ID (e.g: 0xStation)
0xStation has adopted an approach for ERC-6551 to manage and store reputational data on-chain. The reputation here is derived from the active participation of members within the working group, providing a dynamic and transparent metric of engagement. It opens the door to innovative reward distribution schemes that reflect the participants' contributions. For example, one of the first instances of reputation data being used effectively is in the recording of developer call participation.
On-chain Identity and Reputation Systems
ERC-6551 can help create unique on-chain identities that evolve over time, accumulating a history of transactions, rewards, or reputation scores. This can be particularly useful in decentralized autonomous organizations (DAOs) or social token communities, where user reputations can impact governance decisions.
Interactive Artwork
Artists can create dynamic pieces of art that evolve over time based on interactions with owners or other on-chain events. ERC-6551 allows artworks to interact with the blockchain and other on-chain assets, opening up innovative possibilities for generative or interactive art.
Building with Token Bound Accounts
Incorporating Token Bound Accounts into your application is surprisingly simple! I recommend checking out the official documentation for more in-depth info - but you can seamlessly integrate it by installing the official SDK.
$ npm install @tokenbound/sdk-ethers
Using the SDK, you can fetch the ERC-6551 account for an NFT with ethers.js.
getAccount
import { getAccount } from "@tokenbound/sdk-ethers"; const accountAddress = await getAccount( "0xe7134a029cd2fd55f678d6809e64d0b6a0caddcb", // ERC-712 contract address "9", // ERC-721 token ID provider // ethers provider);
createAccount
Deploy the smart contract for a specified ERC-6551 account.
import { createAccount } from "@tokenbound/sdk-ethers";
const { hash } = await createAccount(
"0xe7134a029cd2fd55f678d6809e64d0b6a0caddcb", // ERC-712 contract address
"9", // ERC-721 token ID
signer // ethers signer
);
Additionally, you can use Third Web's smart wallet contracts to help you with this process!
Wrapping it Up
Now you can understand the power that ERC-6551 has, and how you can use it in your own applications for real use cases.
If you like this type of content, stay tuned and subscribe to the newsletter - I’ll launch more of these ERC/EIP blogs and developer guides in the coming weeks! Follow me on my personal Twitter to stay in touch.