PID
Overview
PID
is the core NFT contract that represents Payment ID ownership as ERC-721 tokens. It handles token registration, transfers, and delegates ownership and resolver management to the PIDRegistry contract. This contract implements the tokenized representation of Payment IDs, allowing them to be transferred, approved, and managed like standard NFTs.
Key Concepts
NFT Representation
Each Payment ID is represented as a unique ERC-721 token.
Registry Integration
Maintains synchronization with PIDRegistry when tokens are transferred or registered.
Controller Pattern
Only authorized controller contracts can register new Payment IDs.
Ownership Management
Extends OpenZeppelin's Ownable2Step for secure contract ownership management.
Data Structures
State Variables
registry
IPIDRegistry
Reference to the PID Registry contract.
totalAmount
uint256
Counter for the total number of minted Payment IDs.
controller
address
Address of the authorized controller that can register new tokens.
Functions
Constructor
_initialOwner
address
Address of the initial contract owner.
Initialization
init
_registry
address
Address of the PID Registry contract.
_controller
address
Address of the controller contract.
PID__AlreadyInitialized
Thrown when the contract has already been initialized.
PID__InvalidRegistry
Thrown when the registry address is zero.
PID__InvalidController
Thrown when the controller address is zero.
Token Registration
register
id
uint256
The token ID to register.
owner
address
The address that will own the token.
resolver
address
The resolver address for the token.
uint256
The registered token ID.
PID__NameAlreadyTaken
Thrown when the token ID is already registered.
PID__OnlyController
Thrown when caller is not the controller.
Token Transfers
transferFrom
from
address
Current owner of the token.
to
address
Address to receive the token.
tokenId
uint256
ID of the token to transfer.
PID__NotApprovedOrOwner
Thrown when caller is not token owner or approved.
safeTransferFrom
from
address
Current owner of the token.
to
address
Address to receive the token.
tokenId
uint256
ID of the token to transfer.
_data
bytes
Additional data with no specified format.
PID__NotApprovedOrOwner
Thrown when caller is not token owner or approved.
Availability Check
available
id
uint256
Token ID to check availability for.
bool
true
if the token ID is available, false
otherwise.
Internal Functions
_isApprovedOrOwner
spender
address
Address to check for approval.
tokenId
uint256
Token ID to check.
bool
true
if spender is owner or approved, false
otherwise.
_safeMint
_to
address
Address receiving the token.
_tokenId
uint256
ID of token to mint.
_data
bytes
Additional data with no specified format.
Events
RegistryUpdated
(address oldRegistry, address newRegistry)
Emitted when the registry address is updated.
ControllerUpdated
(address oldController, address newController)
Emitted when the controller address is updated.
NameRegistered
(uint256 id, address owner, address resolver)
Emitted when a new Payment ID is registered.
Errors
PID__AlreadyInitialized
Thrown when attempting to initialize an already initialized contract.
PID__InvalidRegistry
Thrown when providing a zero address for the registry.
PID__InvalidController
Thrown when providing a zero address for the controller.
PID__OnlyController
Thrown when a non-controller address calls a controller-only function.
PID__NameAlreadyTaken
Thrown when attempting to register an ID that is already taken.
PID__NotApprovedOrOwner
Thrown when an unauthorized address attempts to transfer a token.
Last updated