User Registry
This smart contract is responsible for registering and managing users in the NFT Protect system and handling affiliate and partner payments.
Last updated
Was this helpful?
This smart contract is responsible for registering and managing users in the NFT Protect system and handling affiliate and partner payments.
Last updated
Was this helpful?
Before diving into each function's details, let's understand some of the key entities, variables, and concepts used in the contract:
NFT Protect: The main system or service that uses the UserRegistry contract.
DID (Decentralized Identifier): A new type of identifier that enables verifiable, decentralized digital identity.
NFTP Coupons: A contract managing coupons that users can use for specific actions.
Successor: A user designated to take over another user's account for specific events.
Arbitrator: A third-party entity or service used to resolve disputes.
Referrer: A user who refers another user to the platform.
Partner: A user or entity with a specific partnership agreement with the platform.
The contract's constructor sets initial values for several key variables and emits the Deployed
event. It also calls the setAffiliatePercent
, setArbitratorRegistry
, and registerDID
functions, establishes a new NFTPCoupons
contract, and transfers ownership of the coupon contract to the message sender.
The contract uses the onlyNFTProtect
modifier to restrict certain function calls to the address stored in the nftprotect
variable.
The contract emits several events to log significant actions, such as changing the arbitrator registry, setting a referrer, registering a DID, or requesting/approving/rejecting a successor.
The contract uses a variety of variables to store data, including public addresses for various system components (like the nftprotect
and metaEvidenceLoader
), the affiliatePercent
for referrers, a numberOfRulingOptions
constant, and several mappings to store referrers, partners, successors, and requests for successors.
The contract defines a SuccessorRequest
struct to store information about a request for a successor, including the user, the successor, the arbitrator, and dispute IDs.
This is the contract's constructor function, which is executed once when the contract is deployed. It initializes the contract with the provided parameters:
areg
: The address of the arbitrator registry.
did
: The decentralized identifier (DID) of the user.
nftprotectaddr
: The address of the NFT Protect service.
Sets the arbitrator registry to a new address. This can only be called by the contract owner. It also emits the ArbitratorRegistryChanged
event.
Sets the percentage of affiliate commission. This function can only be called by the contract owner and emits an AffiliatePercentChanged
event.
Sets a partner with a specific commission percentage. Only the contract owner can call this function. It emits a PartnerSet
event.
This function is used to process payments from users. If the user has coupons and canUseCoupons
is true, a coupon will be used. Otherwise, the function checks that the correct fee is paid and handles the affiliate payment if a referrer exists. The function can only be called by the NFT Protect service.
Registers a new decentralized identifier (DID) for a user. This function can only be called by the contract owner and emits a DIDRegistered
event.
Unregisters a user's decentralized identifier (DID). This function can only be called by the contract owner and emits a DIDUnregistered
event.
Checks whether a user is registered by iterating over all DIDs and checking if the user is identified by any of them.
Returns the maximum score among all DIDs for a user.
Checks if the given address is set as a successor for a user.
Checks if a user has a successor.
Allows a user to request a successor. It requires that the user is registered. The function creates a dispute with the arbitrator service, stores the request, and emits a SuccessorRequested
event.
Fetches the ruling of a dispute about a successor request. If the dispute is resolved, the function sets the successor or rejects the request, depending on the ruling, and deletes the request.