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
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
publicKeyRegistry
IPublicKeyRegistry
Stores the reference to the public key registry contract.
State Variables
_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
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
_publicKeyRegistry
address
Address of the public key registry contract.
Address Management
addr
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
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
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
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
owner
address
The address to get the nonce for.
Returns
uint256
The current nonce value.
Events
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
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.
Last updated