🔓Locked721

Locked721Base

Legitimate maps each unique digital ID to a token on a decentralized blockchain network. For simplicity and consistency, our documentation will refer to each digital ID as a token.

At the core of Legitimate's token smart contracts is the Locked721Base smart contract.

The Locked721Base smart contract is an implementation of ERC-5192.

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.

ILocked721Base provides the high level interface for setting and getting the locked state of each token. Furthermore, ILocked721Base defines claim, which is a function designed for API_DELEGATE users to transfer locked tokens without modifying their locked state.

Locked721Base is the implementation of the interface. This adds additional functions that allow third-party contracts and users with the role of API_DELEGATE to modify the locked state of each token.

Helper Functions

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.

Options

shouldLockTokensAfterMint

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.

shouldPreventTransferWhenLocked

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.

Locked721 and Locked721Psi

Legitimate provides two default implementations of Locked721Base: Locked721 (an implementation of OpenZeppelin's ERC721 contract) and Locked721Psi (an implementation of ERC721Psi).

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.

_beforeTokenTransfer and _beforeTokenTransfers

These hooks call _shouldPreventTokenTransfer to determine whether or not locked tokens can be transferred by their owners.

_afterTokenTransfers and _afterTokenTransfers

These hooks call _lockTokensAfterTransfer to set the locked state of the transferred tokens after a transfer.

Last updated

Was this helpful?