Using ERC-6551 Token Bound Accounts For Our Metaverse Platform
When we began creating our metaverse platform for NFT communities, there were no token bound accounts available. As a workaround, we centralized player rewards and inventory earned in the game, allowing them to claim those assets to a separate wallet on the blockchain later, though it wasn’t an ideal solution.
Fortunately, before we needed to implement this the ERC-6551 “token bound account” standard was developed, and example implementations were provided. This article explains what ERC-6551 is and shows it being used in a real world example. We will discuss how we leveraged this technology to give our NFTs their own wallets, inventories, and rewards in a completely decentralized way.
What is ERC-6551?
So, what exactly is ERC-6551? In summary, it enables NFTs (ERC-721 tokens) to own one or more smart wallets, which are essentially smart contracts deployed on the blockchain, controlled by the respective NFTs. These smart wallets can run code and implement various standards, making them capable of holding ERC-20 tokens, other NFTs (ERC-721 and ERC-1155 tokens), and ETH.
Using ERC-6551
In our platform the NFT is the player. Users must login with a valid NFT to participate, and will then play and interact with a visual avatar representing the NFT they logged in with. There is no traditional account sign-up process; instead, Web3 wallets and NFTs merge seamlessly.
However, when interacting inside the virtual world these NFTs can still do all the standard things you might expect such as chatting, earning in-game currency, acquiring items and inventory, leveling up, and making friends. Storing inventory or player data points with traditional NFTs can be challenging since they cannot directly “hold” tokens. This is where ERC-6551 comes into play.
Using the ERC-6551 standard, we can provide each NFT (player) with its own wallet, allowing the owner to send and receive tokens both within and outside the game. The NFT’s wallet comes with inventory space to store various types of NFTs, game items, passes, and ERC-20 tokens. This gives the NFT more utility and value, particularly when players invest more time in the ecosystem.
Another exciting feature is the portability of this setup to other platforms. For instance, if a user completes a specific challenge in our platform and is rewarded with a special item NFT and some USDC in their NFT’s wallet, other platforms can easily recognize and allow access to this inventory — the account and data travel with the NFT itself, independent of the platform that created it.
The User Flow
To ensure a smooth user experience, we’ve designed the interface to resemble a traditional player profile. Players don’t need to know the technicalities of ERC-6551 or that their NFT has a token bound account associated with it. By presenting it like a standard player profile, users can intuitively understand the process and engage seamlessly.
To start, our platform lists the NFTs owned by the users connected wallet. This would be just like seeing different characters in an MMO for example. Each is a separate player with which you can enter the system.
Clicking on the Info button here will check the blockchain to see if a token bound account (which remember is just a smart contract) actually exists for this NFT. Since token bounds accounts are owned by the NFT they may have already created one on another platform elsewhere — and if so there is no need for them to create another one and no reason we can’t show them the contents of the wallet as well. If a wallet does exist, that smart contract address is returned and we are able to query it. Doing so we can make a few familiar calls and show what is in this NFTs wallet, like so:
As you can see this NFT holds some ETH, some $ONE tokens (our platform ERC-20 token) and 2 other “standard” NFTs. The owner of this NFT can spend this ETH, these tokens or transfer or sell these NFTs just as a normal wallet would, really bringing the NFT to life.
Note, if the NFT does not initially have a token bound account we can simply ask the user if they would like to create one. Remember, a user could do this from anywhere and every token bound account is unique, so perhaps in your platform or application you can offer to give the user some free or bonus tokens if they do.
Conclusion
In conclusion, incorporating ERC-6551 token bound accounts into our metaverse platform has empowered our NFTs with their own wallets, inventories, and rewards. This technology enhances the functionality and usefulness of existing NFTs, transforming them from mere digital assets into dynamic and interactive elements.
For our business, this implementation allows us to expand the platform and reward users with the confidence that we have a scalable solution for evolving and enhancing player inventories as we introduce new features in the future. By adopting this decentralized approach, we avoid centralizing storage and align with the goals of Web3’s decentralization.
Player One Universe is an open Web3 platform that enables NFT communities to interact and collaboratively build their own unique “Miniverse” virtual worlds and create 3D avatars.