l view returns (bool)
```
| Input Parameter | Type | Description |
| --------------- | ------- | ------------------------------ |
| spender | address | Address to check for approval. |
| tokenId | uint256 | Token ID to check. |
| Returns | Description |
| ------- | ---------------------------------------------------------- |
| bool | `true` if spender is owner or approved, `false` otherwise. |
\_safeMint
```solidity
function _safeMint(address _to, uint256 _tokenId, bytes memory _data) internal virtual override(ERC721)
```
| Input Parameter | Type | Description |
| --------------- | ------- | ----------------------------------------- |
| \_to | address | Address receiving the token. |
| \_tokenId | uint256 | ID of token to mint. |
| \_data | bytes | Additional data with no specified format. |
### Events
| Event | Parameters | Description |
| ----------------- | ---------------------------------------------- | ----------------------------------------------- |
| 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
| Error | Description |
| ------------------------- | ---------------------------------------------------------------------- |
| 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. |
# PIDRegistry
### Overview
`PIDRegistry` is a core contract in the Payment ID system that manages the mapping between tokenIds and their respective owners and resolvers. It serves as the central registry for all Payment ID records, maintaining ownership information and resolver configurations for each tokenId.
### Key Concepts
| Concept | Description |
| --------------------- | --------------------------------------------------------------------------------- |
| Record Management | Stores and manages owner and resolver information for each tokenId. |
| Authorization Control | Ensures only authorized parties (token owner or PID contract) can modify records. |
| Ownership Tracking | Maintains a record of who owns each tokenId. |
| Resolver Assignment | Associates each tokenId with a resolver contract that handles address resolution. |
### Data Structures
State Variables
| Name | Type | Description |
| ------- | -------------------------- | ---------------------------------------------------------------------------- |
| records | mapping(uint256 => Record) | Private mapping that stores owner and resolver information for each tokenId. |
| pid | address | Address of the PID token contract that is authorized to modify records. |
Custom Types
| Type | Structure | Description |
| ------ | ---------------------------------- | ------------------------------------------------------------------ |
| Record | {address owner; address resolver;} | Structure containing owner and resolver information for a tokenId. |
### Functions
Constructor
```solidity
constructor(address _pid) public
```
| Input Parameter | Type | Description |
| --------------- | ------- | ---------------------------------- |
| \_pid | address | Address of the PID token contract. |
| Reverts | Description |
| -------------------------------- | --------------------------------------------- |
| PIDRegistry\_\_InvalidPIDAddress | Thrown when the provided PID address is zero. |
Record Management
setRecord
```solidity
function setRecord(uint256 _tokenId, address _owner, address _resolver) external
```
| Input Parameter | Type | Description |
| --------------- | ------- | -------------------------------------- |
| \_tokenId | uint256 | The token ID to update the record for. |
| \_owner | address | The new owner address. |
| \_resolver | address | The new resolver address. |
setResolver
```solidity
function setResolver(uint256 _tokenId, address _resolver) public authorised(_tokenId)
```
| Input Parameter | Type | Description |
| --------------- | ------- | ---------------------------------------- |
| \_tokenId | uint256 | The token ID to update the resolver for. |
| \_resolver | address | The new resolver address. |
| Reverts | Description |
| ---------------------------- | ----------------------------------------------------------- |
| PIDRegistry\_\_NotAuthorized | Thrown when caller is not the record owner or PID contract. |
setOwner
```solidity
function setOwner(uint256 _tokenId, address _owner) public authorised(_tokenId)
```
| Input Parameter | Type | Description |
| --------------- | ------- | ------------------------------------- |
| \_tokenId | uint256 | The token ID to update the owner for. |
| \_owner | address | The new owner address. |
| Reverts | Description |
| ---------------------------- | ----------------------------------------------------------- |
| PIDRegistry\_\_NotAuthorized | Thrown when caller is not the record owner or PID contract. |
Getter Functions
owner
```solidity
function owner(uint256 tokenId) external view returns (address)
```
| Input Parameter | Type | Description |
| --------------- | ------- | ---------------------------------- |
| tokenId | uint256 | The token ID to get the owner for. |
| Returns | Description |
| ------- | ----------------------------------- |
| address | The owner of the specified tokenId. |
resolver
```solidity
function resolver(uint256 tokenId) external view returns (address)
```
| Input Parameter | Type | Description |
| --------------- | ------- | ------------------------------------- |
| tokenId | uint256 | The token ID to get the resolver for. |
| Returns | Description |
| ------- | ----------------------------------------------- |
| address | The resolver address for the specified tokenId. |
recordExists
```solidity
function recordExists(uint256 tokenId) external view returns (bool)
```
| Input Parameter | Type | Description |
| --------------- | ------- | ------------------------------------ |
| tokenId | uint256 | The token ID to check existence for. |
| Returns | Description |
| ------- | ------------------------------------------------------------- |
| bool | `true` if a record exists for the tokenId, `false` otherwise. |
### Events
| Event | Parameters | Description |
| ----------- | ------------------------------------------- | --------------------------------------------------- |
| NewResolver | (uint256 indexed tokenId, address resolver) | Emitted when a resolver is set for a tokenId. |
| Transfer | (uint256 indexed tokenId, address owner) | Emitted when ownership of a tokenId is transferred. |
### Errors
| Error | Description |
| -------------------------------- | ------------------------------------------------------------------ |
| PIDRegistry\_\_NotAuthorized | Thrown when a caller attempts to modify a record they don't own. |
| PIDRegistry\_\_InvalidPIDAddress | Thrown when initializing with a zero address for the PID contract. |
# RegistrationController
### Overview
`RegistrationController` is a contract that manages the registration process for Payment ID tokens. The contract allows users to register new Payment IDs and configure their address records across different source types and chains. It enforces registration rules and ensures proper initialization of associated resolver records.
### Key Concepts
| Concept | Description |
| --------------------- | ---------------------------------------------------------------------------------------------- |
| Name Registration | Handles the process of registering a unique Payment ID name and creating the associated token. |
| Address Configuration | Sets up initial address records for newly registered Payment IDs. |
| Availability Check | Verifies that a Payment ID name is available before allowing registration. |
| Token ID Generation | Creates a deterministic token ID by hashing the requested name. |
### Data Structures
State Variables
| Name | Type | Description |
| ----------- | -------------- | ------------------------------------------ |
| pidRegistry | IPIDRegistry | Reference to the PID Registry contract. |
| resolver | PublicResolver | Reference to the Public Resolver contract. |
| pid | IPID | Reference to the PID token contract. |
### Functions
Constructor
```solidity
function constructor(
address _pidRegistry,
address _resolver,
address _pid
) public
```
| Input Parameter | Type | Description |
| --------------- | ------- | ---------------------------------------- |
| \_pidRegistry | address | Address of the PID Registry contract. |
| \_resolver | address | Address of the Public Resolver contract. |
| \_pid | address | Address of the PID token contract. |
Registration
register
```solidity
function register(
string calldata name,
uint256[] calldata sourceTypes,
uint256[] calldata addrTypes,
bytes[] calldata destAddress
) external
```
| Input Parameter | Type | Description |
| --------------- | ---------- | ----------------------------------------------------------------- |
| name | string | The Payment ID name to register. |
| sourceTypes | uint256\[] | Array of source types (e.g., exchange, wallet). |
| addrTypes | uint256\[] | Array of address types (e.g., blockchain identifiers). |
| destAddress | bytes\[] | Array of destination addresses for each source/address type pair. |
| Reverts | Description |
| ------------------------------------------- | ----------------------------------------------------- |
| RegistrationController\_\_InvalidInput | Thrown when input arrays have mismatched lengths. |
| RegistrationController\_\_AlreadyRegistered | Thrown when sender already owns a Payment ID. |
| RegistrationController\_\_NameAlreadyTaken | Thrown when the requested name is already registered. |
available
```solidity
function available(uint256 _tokenId) public view returns (bool)
```
| Input Parameter | Type | Description |
| --------------- | ------- | ----------------------------------- |
| \_tokenId | uint256 | Token ID to check availability for. |
| Returns | Description |
| ------- | ------------------------------------------------------- |
| bool | `true` if the token ID is available, `false` otherwise. |
Internal Functions
\_setAddresses
```solidity
function _setAddresses(
uint256 tokenId,
uint256[] calldata sourceTypes,
uint256[] calldata addrTypes,
bytes[] calldata destAddress
) internal
```
| Input Parameter | Type | Description |
| --------------- | ---------- | ----------------------------------------------------------------- |
| tokenId | uint256 | The token ID to set addresses for. |
| sourceTypes | uint256\[] | Array of source types (e.g., exchange, wallet). |
| addrTypes | uint256\[] | Array of address types (e.g., blockchain identifiers). |
| destAddress | bytes\[] | Array of destination addresses for each source/address type pair. |
### Errors
| Error | Description |
| ------------------------------------------- | ----------------------------------------------------- |
| RegistrationController\_\_InvalidInput | Thrown when input arrays have mismatched lengths. |
| RegistrationController\_\_AlreadyRegistered | Thrown when sender already owns a Payment ID. |
| RegistrationController\_\_NameAlreadyTaken | Thrown when the requested name is already registered. |
# AddrResolver
### Overview
AddrResolver is an abstract contract responsible for managing address records associated with Payment ID tokens, supporting both direct updates and signature-based authorization.
### Key Concepts
| Concept | Description |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| **Address Resolution** | Stores address mappings for Payment ID tokens, allowing structured lookup and updates. |
| **EIP-712 Signature-Based Updates** | Enables gasless transactions using off-chain signatures, ensuring security through nonce management and signature verification. |
| **Public Key Registry Integration** | Ensures ownership validation by linking public keys to addresses. |
### Data Structures
#### Immutable Components
| Name | Type | Description |
| ------------------- | -------------------- | --------------------------------------------------------- |
| `publicKeyRegistry` | `IPublicKeyRegistry` | Stores the reference to the public key registry contract. |
#### State Variables
| Name | Type | Description |
| -------- | ------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| `_addrs` | `mapping(uint256 => mapping(uint256 => mapping(uint256 => bytes)))` | Nested mapping storing addresses for different source and address types per token. |
| `nonces` | `mapping(address => uint256)` | Tracks the nonce for each address to prevent replay attacks. |
#### Type Hashes
| Name | Type | Description |
| ------------------------- | --------- | ------------------------------------------------------- |
| `SET_ADDR_TYPEHASH` | `bytes32` | Type hash for setting a single address via signature. |
| `BATCH_SET_ADDR_TYPEHASH` | `bytes32` | Type hash for setting multiple addresses via signature. |
### Functions
#### Initialization
**Constructor**
```solidity
constructor(address _publicKeyRegistry)
```
| Input Parameter | Type | Description |
| -------------------- | --------- | -------------------------------------------- |
| `_publicKeyRegistry` | `address` | Address of the public key registry contract. |
#### Address Management
**addr**
```solidity
function addr(uint256 tokenId, uint256 sourceType, uint256 addrType) external view returns (bytes memory)
```
| Input Parameter | Type | Description |
| --------------- | -------------- | ------------------------------- |
| `tokenId` | `uint256` | ID of the token. |
| `sourceType` | `uint256` | Type of source for the address. |
| `addrType` | `uint256` | Type of address to retrieve. |
| **Returns** | `bytes memory` | The stored address record. |
**setAddr**
```solidity
function setAddr(uint256 tokenId, uint256 sourceType, uint256 addrType, bytes memory newAddr) external
```
| Input Parameter | Type | Description |
| --------------- | -------------- | ------------------------------- |
| `tokenId` | `uint256` | ID of the token. |
| `sourceType` | `uint256` | Type of source for the address. |
| `addrType` | `uint256` | Type of address to set. |
| `newAddr` | `bytes memory` | The new address value. |
#### Signature-Based Address Management
**setAddrWithSig**
```solidity
function setAddrWithSig(uint256 tokenId, uint256 sourceType, uint256 addrType, bytes memory newAddr, address owner, bytes calldata signature) external
```
| Input Parameter | Type | Description |
| --------------- | ---------------- | --------------------------------- |
| `tokenId` | `uint256` | ID of the token. |
| `sourceType` | `uint256` | Type of source for the address. |
| `addrType` | `uint256` | Type of address to set. |
| `newAddr` | `bytes memory` | The new address value. |
| `owner` | `address` | The owner authorizing the change. |
| `signature` | `bytes calldata` | The EIP-712 signature. |
**batchSetAddrWithSig**
```solidity
function batchSetAddrWithSig(uint256 tokenId, uint256[] calldata sourceTypes, uint256[] calldata addrTypes, bytes[] calldata newAddrs, address owner, bytes calldata signature) external
```
| Input Parameter | Type | Description |
| --------------- | ---------------- | --------------------------------- |
| `tokenId` | `uint256` | ID of the token. |
| `sourceTypes` | `uint256[]` | Array of source types. |
| `addrTypes` | `uint256[]` | Array of address types. |
| `newAddrs` | `bytes[]` | Array of new address values. |
| `owner` | `address` | The owner authorizing the change. |
| `signature` | `bytes calldata` | The EIP-712 signature. |
#### Nonce Management
**getNonce**
```solidity
function getNonce(address owner) external view returns (uint256)
```
| Input Parameter | Type | Description |
| --------------- | --------- | --------------------------------- |
| `owner` | `address` | The address to get the nonce for. |
| **Returns** | `uint256` | The current nonce value. |
### Events
| Event | Parameters | Description |
| ---------------------------- | --------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
| `AddressChanged` | `(uint256 tokenId, uint256 sourceType, uint256 addrType, bytes newAddr)` | Emitted when an address record is updated. |
| `AddressChangedWithSig` | `(uint256 tokenId, uint256 sourceType, uint256 addrType, bytes newAddr, uint256 nonce)` | Emitted when an address is updated using a signature. |
| `BatchAddressChangedWithSig` | `(uint256 tokenId, uint256 nonce)` | Emitted when multiple addresses are updated using a signature. |
### Errors
| Error | Description |
| ----------------------------------- | --------------------------------------------------------------------- |
| `AddrResolver__InvalidSignature` | Thrown when a signature is invalid. |
| `AddrResolver__InvalidPublicKey` | Thrown when the recovered public key is not associated with an owner. |
| `AddrResolver__ArrayLengthMismatch` | Thrown when input arrays have different lengths. |
# PublicResolver
### Overview
`PublicResolver` is a contract that provides additional functionality for managing operator approvals and registration controllers for Payment ID tokens. The contract supports both direct and signature-based authorization.
### Key Concepts
| Concept | Description |
| ----------------------------- | ------------------------------------------------------------------------------------- |
| **Operator Approvals** | Allows owners to authorize operators to manage their Payment ID tokens. |
| **Signature-Based Approvals** | Enables gasless approvals using EIP-712 signatures. |
| **Registration Controller** | Manages centralized registration operations and is initialized once. |
| **PID Registry Integration** | Ensures authorization consistency by verifying token ownership with the PID registry. |
### Data Structures
#### Immutable Components
| Name | Type | Description |
| --------------------------- | --------- | ---------------------------------------------- |
| `APPROVAL_FOR_ALL_TYPEHASH` | `bytes32` | Type hash for operator approval via signature. |
#### State Variables
| Name | Type | Description |
| ------------------------ | ---------------------------------------------- | -------------------------------------------------- |
| `pidRegistry` | `IPIDRegistry` | Stores the reference to the PID registry contract. |
| `registrationController` | `address` | Stores the address of the registration controller. |
| `_operatorApprovals` | `mapping(address => mapping(address => bool))` | Mapping tracking operator approvals for owners. |
### Functions
#### Initialization
**Constructor**
```solidity
constructor(address _pidRegistry, address _publicKeyRegistry)
```
| Input Parameter | Type | Description |
| -------------------- | --------- | -------------------------------------------- |
| `_pidRegistry` | `address` | Address of the PID registry contract. |
| `_publicKeyRegistry` | `address` | Address of the public key registry contract. |
**init**
```solidity
function init(address _registrationController) external
```
| Input P프로젝트로 돌아가기