🎉 Hey Gate Square friends! Non-stop perks and endless excitement—our hottest posting reward events are ongoing now! The more you post, the more you win. Don’t miss your exclusive goodies! 🚀
🆘 #Gate 2025 Semi-Year Community Gala# | Square Content Creator TOP 10
Only 1 day left! Your favorite creator is one vote away from TOP 10. Interact on Square to earn Votes—boost them and enter the prize draw. Prizes: iPhone 16 Pro Max, Golden Bull sculpture, Futures Vouchers!
Details 👉 https://www.gate.com/activities/community-vote
1️⃣ #Show My Alpha Points# | Share your Alpha points & gains
Post your
In-depth analysis of the underlying principles of ERC-6551
Written by: @0xCygaar Translated by: MetaCat
This article is a brief description of how ERC-6551 enables any NFT to own any type of crypto asset.
Let's start with what's actually happening with most NFTs.
NFTs on Ethereum are just data entries in smart contracts that tell you who owns the NFT, who can transfer the NFT, and what the metadata of the NFT looks like. Here is a function that returns information about a given NFT:
Get the Owner of a given NFT
Get the tokenURI of a given NFT
Get the wallet address where the given NFT is approved
When you mint NFT, you just set the value of the data entry owner (wallet address). When you transfer an NFT, you just change the owner's value (wallet address). The following two pictures are related codes of ownership settings in the ERC721 contract:
The mint function in the ERC721 contract
The transfer function in the ERC721 contract
Most NFT contracts are that simple. As we saw above, there is no code enabling these NFTs to own other NFTs, ETH or ERC20 tokens.
Smart contracts cannot be changed, so how does ERC-6551 allow any NFT to own other assets?
The answer is: registry + contract wallet.
A smart contract wallet (CA wallet) is simply a smart contract that can receive NFT, ERC20 or ETH and additionally perform arbitrary transactions. These contract wallets have their own addresses (like all smart contracts).
If you're not familiar with registries, you can think of them as individual smart contracts that store information. The ERC-6551 registry contains: information stating which NFTs are mapped to which smart contract wallets, and it also uses a proxy to create a smart contract wallet (it doesn't matter if you know that).
Registry contract code?
For example, Azuki #4567 might map to a smart contract wallet at address 0x243F4E0d556EFD1006c52E85A6ddFb6748A4C0b7. One NFT can control multiple contract accounts, but each contract account only belongs to one NFT, as shown in the figure below:
Well, we now have a registry that can create wallets for NFTs and link NFTs to wallets, and this NFT-bound wallet can now be used as a normal wallet. This wallet can transfer ETH, buy NFT or Swap ERC20 tokens, of course the transaction must be initiated by the NFT owner.
I want to reiterate that these NFT-bound wallets are smart contracts. They are similar to multi-signature wallets in that someone must call a function on the contract in order for the wallet to perform certain actions. For ERC-6551 wallets, the NFT owner will call uteCall on the wallet to initiate the transaction.
So what's so special about these NFT-bound wallets? When the owner who controls the NFT changes, the control of the wallet also changes simultaneously. Controlling NFT means that you control everything in the NFT-bound wallet, and NFT will transform from a single asset to a bundled asset package.
TL;DR: ERC-6551 enables all NFTs to have a wallet by using a registry and smart contract wallet. The registry creates a contract wallet and associates the contract wallet with the NFT. Contract wallets can hold other assets, and only the owner of the NFT can perform transactions on this wallet.