Locked721
Last updated
Was this helpful?
Last updated
Was this helpful?
At the core of Legitimate's token smart contracts is the Locked721Base
smart contract.
The Locked721Base
smart contract is an implementation of .
However, the Locked721Base
contract adds additional functionality that makes the tokens locked state mutable.
Each token can be locked or unlocked individually, providing granular control over the locked state.
provides the high level interface for setting and getting the locked state of each token. Furthermore, ILocked721Base defines , which is a function designed for API_DELEGATE
users to transfer locked tokens without modifying their locked state.
is the implementation of the interface. This adds additional functions that allow third-party contracts and users with the role of to modify the locked state of each token.
Locked721Base
itself does not implement IERC721
. This is intentional in design. Locked721Base
is an abstract class that allows developers to chose their own ERC721
implementation. However, Locked721Base
provides two helper methods designed to be called within the hooks an ERC721
implementation
This helper function will return true if a token is locked and the option shouldPreventTransferWhenLocked
is true
This helper function will iterate through a set of tokenIds
and set the locked state to true.
If the calling method is a mint
call (the from
address is 0x0
) and shouldLockTokensAfterMint
is set to false, then this function will not set the locked state to true
.
This is a configurable option in the contract that defines whether or not tokens should be auto-locked after mint. By default, this is set to true.
This is a configurable option that determines whether any token in a locked state can be transfered successfully. If this flag is set to true, any transaction that attempts to transfer a locked token will revert. By default, this is set to true.
Each of these are representative of their own ERC721 implementation. We won't get into too much detail about each of the underlying ERC721 implementations, but we will cover how both of these contracts implement Locked721Base
.
Legitimate provides two default implementations of Locked721Base
: (an implementation of ) and (an implementation of ).
and
These hooks call to determine whether or not locked tokens can be transferred by their owners.
and
These hooks call to set the locked state of the transferred tokens after a transfer.