How to use Token Bound Account (ERC-6551)

Joan Alavedra6 min read
How to use Token Bound Account (ERC-6551)

ERC-6551 is a standard that allows ERC-721 NFTs to have their own smart contract accounts. These are often called Token Bound Accounts (TBA). By giving an NFT its own account, the token can own other digital assets and interact with applications directly.

What is a Token Bound Account (ERC-6551)?

A Token Bound Account is a smart contract wallet that is permanently linked to a specific NFT. This allows the NFT to function as an onchain identity that can own tokens, sign transactions, and hold its own inventory. Because the account is tied to the token, transferring the NFT also transfers ownership of the associated account and its assets.

The ERC-6551 mechanism consists of three key parts: a registry, an account interface, and a minimal proxy implementation. The registry is permissionless and immutable, and it deploys a smart contract account for an NFT.

The account interface sets the standard process, rules, and limits for account creation. ERC-1167 minimal proxy contracts are used in deploying accounts, making account implementations much easier and cheaper.

ERC-6551 is an improvement over ERC-721 because it overcomes some of the limitations of ERC-721. ERC-721 tokens are static and can only show static data or information. They are also not composable and cannot interact with other onchain assets or contracts independently. ERC-6551, on the other hand, maintains backwards compatibility with previously minted ERC-721 NFTs and deploys smart contract accounts for NFTs via a permissionless registry.

Check the technical ERC-6551 proposal as well as the non-technical write up from the authors.

How ERC-6551 Improves Gaming

In many onchain games, a player's character is represented by an NFT, while their items (swords, potions, armor) are separate tokens in their wallet. This can be difficult to manage, as the player has to track dozens of individual assets.

With ERC-6551, game developers can create onchain inventories. All items can be owned directly by the character NFT. This makes for a more immersive experience—when you trade your character, the entire inventory moves with it automatically.

Benefits of ERC6551 for gaming

ERC6551 offers a number of benefits for gaming applications, including:

  • Improved user experience: ERC6551 makes it easier for players to manage their game-related assets. You can now create a smart account via a minted or airdropped NFT
  • Enhanced gameplay: ERC6551 can be used to create more immersive and engaging gameplay experiences. For example, players could use ERC6551 to equip their characters with different weapons and armor, or to purchase items from in-game shops.
  • Increased security: ERC6551 can help to improve the security of game assets. This is because token-bound accounts are more secure than traditional wallets (EOAs). Overall, ERC6551 is a valuable tool for gaming applications. It can be used to improve the user experience, enhance gameplay, and increase security.

Challenges and Limitations of ERC-6551

While ERC-6551 brings a new layer of functionality to NFTs, it also introduces a set of challenges and limitations:

  1. Complex NFT User Experience: ERC-6551 adds additional features and capabilities to NFTs, which also brings a new layer of complexity. Users need to have a higher level of understanding to fully utilize these advancements.
  2. Implementation Complexity: Implementing the ERC-6551 standard into existing ERC-721 tokens requires creating and configuring a new smart contract. This process can be complex and requires technical expertise. Additionally, it may involve paying for the services of a blockchain developer.

At Openfort we want to overcome these challenges by smoothing and standardizing the interactions directly via APIs, offering an already build implementation catered towards onchain gaming.

Let’s see how we’ve done this.

Combining ERC-6551 and Account Abstraction

Giving an NFT its own smart wallet is a major step forward for player experience. By combining ERC-6551 with ERC-4337 (Account Abstraction), we can create "wallet-less" experiences where the underlying technical complexity is hidden from the player.

At Openfort, we explore how these standards can work together to enable gasless transactions and pop-up-free gameplay for character-driven games.

Option 1: NFT is owned by an Openfort 4337 account

Group 348.svg

The first option drops an ERC721 into a newly created smart wallet with Openfort. The ERC721 is 6551 compatible allowing it to store the different in-game assets, while the interactions happen at the Openfort level (4337 compatible) ensuring there is a smooth player experience -gasless txs and zero txs prompts.

Nevertheless this option has constraints because the actions need to be encoded before sent and get the new owner from the logs via the implementation ABI. All in all:

  • (+) It uses session keys, which can enable a popup-less experience for users.

  • (-) You deploy two smart wallets making it more costly to interact.

  • (-) While the implementation works with Openfort it is cumbersome to use via the API.

Option 2: NFT is owned by an EOA and EIP6551 account is EIP4337 compliant

Group 349.svg

This option reduced the complexity of the implementation, because now you don’t need to deploy two smart contract wallets but rather make the TBA compatible with ERC4337 directly while the EOA has the ERC721 ownership.

The main disadvantage here is that you need to be careful the way you apply session keys within the game in the case an NFT owner decides to transact their token.

All in all:

  • (+) It reduces the complexity of the solution while also lowering the gas spending (you only create one smart wallet instead of two).
  • (~) You can still benefit from session keys in your game but need to make sure to revoke them if the NFT is transferred to a new owner.

How can I use Token Bound Accounts with Account Abstraction?

Openfort’s 4337 account and a 6551 account are quite similar. The main difference is that the ownership of the 4337 account is defined by who has the signer and the ownership of the 6551 account is defined by who has the NFT.

Both have therefore the option of transferring ownership.

  • For the 6551 account, approve and transfer the ownership of the NFT.
  • For the 4337 account, transfer ownership of the account.
Share this article

Keep Reading