NFT Protect
This smart contract implements security measures for Non-Fungible Tokens (NFTs). It provides mechanisms for owners to restore ownership if access to a protected token is lost or stolen,
The contract code can be found here.
Variables
requestsCounter
: Tracks the total number of ownership requests.requests
: Mapping of request numbers toRequest
struct instances.disputeToRequest
: Mapping of dispute IDs to request numbers.tokenToRequest
: Mapping of token IDs to request numbers.metaEvidences
: Mapping ofMetaEvidenceType
to evidence strings.metaEvidenceLoader
: Address allowed to submit meta evidence.burnOnAction
: Boolean flag determining if tokens should be burned upon action.arbitratorRegistry
: Instance of anIArbitratorRegistry
contract.userRegistry
: Instance of anIUserRegistry
contract.
Modifiers
onlyOwner
: Ensures that the caller is the owner of the contract.
Events
OwnershipRestoreAsked
: Emitted when an ownership restoration request is made.OwnershipAdjustmentAnswered
: Emitted when an ownership adjustment request is answered.OwnershipRestoreAnswered
: Emitted when an ownership restoration request is answered.BurnAnswered
: Emitted when a burn request is answered.
Functions
setFee
This function allows the contract owner to set the fee associated with a given security level. The fee is required for certain operations within the contract.
setArbitratorRegistry
This function allows the contract owner to set the address of the arbitrator registry. The arbitrator registry is a contract that manages arbitrators who make decisions in disputes.
setUserRegistry
This function allows the contract owner to set the address of the user registry. The user registry is a contract that manages the users of the system.
setBurnOnAction
This function allows the contract owner to set whether protected tokens should be burned when an action is taken. If set to true, the protected tokens will be destroyed, effectively reducing the total supply of tokens.
setBase
This function allows the contract owner to set the base URI for all token metadata. The base URI is prepended to the token-specific identifiers to generate the full URI for each token.
setScoreThreshold
This function allows the contract owner to set the threshold for user scores. This score threshold may be used in various operations within the contract, for example, to determine if a user can perform certain actions.
setMetaEvidenceLoader
This function allows the contract owner to set the address of the meta evidence loader. The meta evidence loader is a contract that manages the submission of meta evidence.
onERC721Received
This function is a standard interface for handling incoming ERC721 tokens. It's called by an ERC721 smart contract when a token is transferred to this contract.
onERC1155Received
This function is a standard interface for handling incoming ERC1155 tokens. It's called by an ERC1155 smart contract when a token is transferred to this contract.
onERC1155BatchReceived
This function is a standard interface for handling incoming batches of ERC1155 tokens. It's called by an ERC1155 smart contract when multiple tokens are transferred to this contract at once.
tokenURI
This function returns the full URI for the metadata associated with the token specified by tokenId
. It's part of the standard interface for ERC721 tokens and is used to provide information about the token.
originalOwnerOf
This function is used to determine the original owner of the token specified by tokenId
. This information can be used to track the provenance of tokens.
isOriginalOwner
This function checks whether the given address is the original owner of the token with the specified tokenId
. This can be useful in functions that need to validate the original owner.
protect
This function allows a user to protect their token by transferring it to this contract. In return, the contract mints a protected token that represents the original token. The protected token can be transferred or sold independently of the original token.
burn
This function allows a user to burn their protected token and return the original token to the owner. If the token's security level is not Basic, a dispute is created and the evidence is passed to the arbitrator for resolution.
adjustOwnership
This function allows a user to adjust the ownership of the original token to the current owner of the protected token. If the token's security level is not Basic, a dispute is created and the evidence is passed to the arbitrator for resolution.
askOwnershipAdjustment
This function allows a user to create a request for ownership adjustment. This can be useful if the ownership of the original token has become inconsistent with the ownership of the protected token.
answerOwnershipAdjustment
This function allows the owner of the original token to confirm or reject a proposed ownership adjustment. The owner can provide evidence to support their decision.
askOwnershipAdjustmentArbitrate
This function allows a user to escalate an unresolved ownership adjustment request to an external arbitrator. The user can provide additional evidence to support their case.
askOwnershipRestoreArbitrate
This function allows the original owner of a token to open a dispute if they have lost access to their protected token. The dispute is passed to an ERC-792 compatible external arbitrator for resolution.
submitMetaEvidence
This function allows the meta evidence loader to submit meta evidence of a certain type. The evidence can be used in disputes to provide additional context or information.
rescueERC20
This function allows the contract owner to transfer a specified amount of any ERC20 token that has become stuck in the contract to a specified receiver.
Structs
Request
: Contains the details of an ownership request or dispute.
Enums
MetaEvidenceType
: Defines the types of meta-evidence.ReqType
: Defines the types of requests.Status
: Defines the statuses of requests.Security
: Defines the security levels of tokens.
Notes
The function askOwnershipRestoreArbitrate
requires the sender to be the original owner of the token and the token to exist. Additionally, it requires that the sender is not currently the owner or approved spender of the token, and that the specified MetaEvidenceType
is valid.
The fetchRuling
function fetches the ruling of a given request and updates the request's status based on the ruling. If the ruling is accepted, it carries out the corresponding action based on the request type, which could be an ownership adjustment, ownership restoration, or token burn.
Last updated