<aside>
🚧 Work in progress! See https://github.com/violetprotocol/ERC1238-token/pull/5 and open questions below.
</aside>
This extension enables staking NTTs in a smart contract. Since NTTs are non-transferable, the usual way of staking tokens by transferring ownership over them is not possible.
However, the way to achieve staking that has been considered is to introduce the notion of token holders, in addition to token owners:
- When minting tokens to address A of Alice, address A is the token owner but also the initial token holder. Alice can then entrust address B with her tokens. Address B becomes the token holder while Alice remains the token owner.
- Only one address can hold specific tokens at a time.
- A token holder can transfer tokens to another holder. Still, the important point is that this does not change ownership of the tokens.
- Because token holders can “transfer” tokens to any address they choose, they can also send them to the zero address and have it hold these tokens forever. So effectively token owners are putting their tokens at stake with this mechanism.
- The rules for burning tokens are still up to the applications developers. It’s important that token holding does not conflict with the ability for issuers to burn token (ownership) for example, even when tokens are staked. But in this scenario, smart contracts holding tokens will be notified so that they can handle the situation appropriately.
Mapping
// Mapping holder => id => balance
mapping(address => mapping(uint256 => uint256)) private _heldBalances;