Solidity API
PhygitalRedeemer1155
Allows for ERC-1155 token owners to burn their tokens to redeem physical items. Upon sucessful physical redemption, a proof-of-redemption soulbound ERC-721 token is minted to the item's recipient.
isRequestOwner
modifier isRequestOwner(bytes encodedRequest)
Modifier to make a function callable only when the msg.sender is the request owner.
constructor
constructor(contract IPhygitalRedeemerRegistry _registry, address _token, address _provider, bytes32 _providerPublicKey, uint256 _maxFulfillmentDuration, address _openRequestHooks, string _name, string _symbol, string baseTokenURI_) public
getRequestBeneficiary
function getRequestBeneficiary(bytes encodedRequest) public pure returns (address beneficiary)
Returns the beneficiary of the soulbound token.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | Encoded request whose beneficiary should be returned. |
Name | Type | Description |
---|---|---|
beneficiary | address | Owner of the given request. |
_decodeRequest
function _decodeRequest(bytes encodedRequest) internal pure returns (struct IPhygitalRedeemer1155.Request1155 request)
Decode an encoded Request1155 struct.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | Encoded Request1155 struct. |
Name | Type | Description |
---|---|---|
request | struct IPhygitalRedeemer1155.Request1155 | Decoded Request1155 struct. |
_transferUserTokens
function _transferUserTokens(bytes encodedRequest) internal
Returns the deposited ERC-721 or ERC-1155 token(s) back to the user who opened the given request.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | The encoded request for which the underlying tokens should be returned to the user. |
_burnTokens
function _burnTokens(bytes encodedRequest) internal
Burns the ERC-721 or ERC-1155 tokens that were deposited by the user once the given request was opened.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | The encoded request for which the underlying tokens should be burnt. |
_transferEscrowToRedeemer
function _transferEscrowToRedeemer(bytes encodedRequest) internal
Utility function, transfers the escrowed payment to the redeemer.
openRequest
function openRequest(bytes32 publicKey, bytes32 nonce, uint256[] tokenIds, uint256[] amounts, bytes shippingAddress, address paymentToken) external payable returns (bytes32 requestId)
Opens a new request with ERC20 token used in redemption fee.
Name | Type | Description |
---|---|---|
publicKey | bytes32 | Public key of the redeemer. |
nonce | bytes32 | Unique nonce for the redemption request. |
tokenIds | uint256[] | Token IDs to redeem. |
amounts | uint256[] | Amounts of each token ID to redeem. |
shippingAddress | bytes | Encrypted shipping address. |
paymentToken | address | Address of the payment token, address(0) for native. |
Name | Type | Description |
---|---|---|
requestId | bytes32 | Unique ID for the opened request. |
_openRequest
function _openRequest(bytes32 publicKey, bytes32 nonce, uint256[] tokenIds, uint256[] amounts, bytes shippingAddress) internal returns (bytes32 requestId)
PhygitalRedeemer721
Allows for ERC-721 token owners to burn their tokens to redeem physical items. Upon sucessful physical redemption, a proof-of-redemption soulbound ERC-721 token is minted to the item's recipient.
defaultBurnMechanism
enum IPhygitalRedeemer721.BurnMechanism defaultBurnMechanism
Default burn mechanism for new redemption requests.
burnMechanism
mapping(uint256 => enum IPhygitalRedeemer721.BurnMechanism) burnMechanism
Mapping of tokenIds to their custom burn mechanism type
isRedeemed
mapping(uint256 => bool) isRedeemed
Maps if a tokenId has been redeemed only for tokens with BurnMechanism.Mark
isRequestOwner
modifier isRequestOwner(bytes encodedRequest)
Modifier to make a function callable only when the msg.sender is the request owner.
constructor
constructor(contract IPhygitalRedeemerRegistry _registry, address _token, address _provider, bytes32 _providerPublicKey, uint256 _maxFulfillmentDuration, address _openRequestHooks, string _name, string _symbol, string baseTokenURI_, enum IPhygitalRedeemer721.BurnMechanism _defaultBurnMechanism) public
setDefaultBurnMechanism
function setDefaultBurnMechanism(enum IPhygitalRedeemer721.BurnMechanism burnMechanism_) external
Sets the default burn mechanism for the entire collection
Name | Type | Description |
---|---|---|
burnMechanism_ | enum IPhygitalRedeemer721.BurnMechanism |
setBurnMechanismForToken
function setBurnMechanismForToken(uint256 tokenId, enum IPhygitalRedeemer721.BurnMechanism burnMechanism_) external
Sets if a redeemed ERC721 will be burned, marked as already redeemed or returned to owner
Name | Type | Description |
---|---|---|
tokenId | uint256 | Token ID to be redeemed |
burnMechanism_ | enum IPhygitalRedeemer721.BurnMechanism |
setBurnMechanismForTokens
function setBurnMechanismForTokens(uint256[] tokenIds, enum IPhygitalRedeemer721.BurnMechanism burnMechanism_) external
Sets the burn mechanism for a batch of tokens
Name | Type | Description |
---|---|---|
tokenIds | uint256[] | Token IDs to set redemption type for |
burnMechanism_ | enum IPhygitalRedeemer721.BurnMechanism |
getRequestBeneficiary
function getRequestBeneficiary(bytes encodedRequest) public pure returns (address beneficiary)
Returns the beneficiary of the soulbound token.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | Encoded request whose beneficiary should be returned. |
Name | Type | Description |
---|---|---|
beneficiary | address | Owner of the given request. |
_decodeRequest
function _decodeRequest(bytes encodedRequest) internal pure returns (struct IPhygitalRedeemer721.Request721)
Decode an encoded Request721 struct.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | Encoded Request721 struct. |
Name | Type | Description |
---|---|---|
[0] | struct IPhygitalRedeemer721.Request721 | request Decoded Request721 struct. |
_transferUserTokens
function _transferUserTokens(bytes encodedRequest) internal
Returns the deposited ERC-721 or ERC-1155 token(s) back to the user who opened the given request.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | The encoded request for which the underlying tokens should be returned to the user. |
_burnTokens
function _burnTokens(bytes encodedRequest) internal
Burns the ERC-721 or ERC-1155 tokens that were deposited by the user once the given request was opened.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | The encoded request for which the underlying tokens should be burnt. |
_transferEscrowToRedeemer
function _transferEscrowToRedeemer(bytes encodedRequest) internal
Utility function, transfers the escrowed payment to the redeemer.
_openRequest
function _openRequest(bytes32 publicKey, bytes32 nonce, uint256[] tokenIds, bytes shippingAddress) internal returns (bytes32 requestId)
openRequest
function openRequest(bytes32 publicKey, bytes32 nonce, uint256[] tokenIds, bytes shippingAddress, address paymentToken) external payable returns (bytes32 requestId)
Opens a new request with ERC20 token used in redemption fee
Name | Type | Description |
---|---|---|
publicKey | bytes32 | Public key of the redeemer. |
nonce | bytes32 | Unique nonce for the redemption request. |
tokenIds | uint256[] | Token IDs to be redeemed. |
shippingAddress | bytes | Encrypted shipping address. |
paymentToken | address | Address of the payment token, address(0) for native. |
Name | Type | Description |
---|---|---|
requestId | bytes32 | Unique ID for the opened request. |
PhygitalRedeemerCommon
Contains functionality that applies to both ERC-721 and ERC-1155 Phygital Redeemers. Both PhygitalRedeemer721 and PhygitalRedeemer1155 inherit this abstract contract.
token
address token
ERC-721 or ERC-1155 Phygital token's address.
provider
address provider
Address of the physical items' provider.
providerPublicKey
bytes32 providerPublicKey
Public key of the physical items' provider.
maxFulfillmentDuration
uint256 maxFulfillmentDuration
Maximum allowed fulfillment duration, in seconds.
openRequestHooks
address openRequestHooks
Hook(s) to be called when a new redemption request is being opened. Can be the zero address, in which case no hooks are called.
requestState
mapping(bytes32 => struct IPhygitalRedeemerCommon.RequestState) requestState
Maps request IDs to request states.
paused
bool paused
True if the contracts are paused, false otherwise.
_baseTokenURI
string _baseTokenURI
Proof-of-redemption default token metadata URI.
_customTokenURI
mapping(uint256 => string) _customTokenURI
Proof-of-redemption custom token metadata URI for tokenID.
feeProcessorAddress
address feeProcessorAddress
Owner
Returns the set fee processor address.
Name | Type | Description |
---|---|---|
protocolFeeAddress
address protocolFeeAddress
Owner
Returns the set protocol fee address.
Name | Type | Description |
---|---|---|
onlyFeeProcessor
modifier onlyFeeProcessor()
constructor
constructor(contract IPhygitalRedeemerRegistry _registry, address _token, address _provider, bytes32 _providerPublicKey, uint256 _maxFulfillmentDuration, address _openRequestHooks, string _name, string _symbol, string baseTokenURI_) internal
Can only be called once, following the contract's creation.
Initializes the Phygital Redeemer.
Name | Type | Description |
---|---|---|
_registry | contract IPhygitalRedeemerRegistry | The registry contract to query the protocol fee and fee processor addresses, and to transfer ownership to. |
_token | address | ERC-721 or ERC-1155 Phygital token's address. |
_provider | address | Address of the physical items' provider. |
_providerPublicKey | bytes32 | Public key of the physical items' provider. |
_maxFulfillmentDuration | uint256 | Maximum allowed fulfillment duration, in seconds. |
_openRequestHooks | address | Contract address implementing hook(s) that will be called when a new redemption request is being opened. Can be the zero address if no such hooks are desired. |
_name | string | Proof-of-redemption token collection name. |
_symbol | string | Proof-of-redemption token collection symbol. |
baseTokenURI_ | string | TODO: document |
getRequestBeneficiary
function getRequestBeneficiary(bytes encodedRequest) public view virtual returns (address beneficiary)
Returns the beneficiary of the soulbound token.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | Encoded request whose beneficiary should be returned. |
Name | Type | Description |
---|---|---|
beneficiary | address | Owner of the given request. |
_validateRequest
function _validateRequest(bytes encodedRequest, enum IPhygitalRedeemerCommon.RequestStatus expectedRequestStatus) internal view
Check whether the given encoded request's status matches the expected request status.
getRequestState
function getRequestState(bytes32 requestId) external view returns (struct IPhygitalRedeemerCommon.RequestState state)
Returns the given request's state.
Name | Type | Description |
---|---|---|
requestId | bytes32 | ID of the request whose state to return. |
Name | Type | Description |
---|---|---|
state | struct IPhygitalRedeemerCommon.RequestState | State associated to the given request. |
isProvider
modifier isProvider()
Modifier to make a function callable only when the msg.sender is the physical item provider.
isNotPaused
modifier isNotPaused()
Modifier to make a function callable only when the contract is not paused.
isValidRequest
modifier isValidRequest(bytes encodedRequest, enum IPhygitalRedeemerCommon.RequestStatus expectedRequestStatus)
Modifier to check whether the given encoded request's status matches the expected request status.
isRequestOwner
modifier isRequestOwner(bytes encodedRequest)
Modifier to make a function callable only when the msg.sender is the request owner.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | The encoded request whose owner to check for. |
_transferUserTokens
function _transferUserTokens(bytes encodedRequest) internal virtual
Returns the deposited ERC-721 or ERC-1155 token(s) back to the user who opened the given request.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | The encoded request for which the underlying tokens should be returned to the user. |
_burnTokens
function _burnTokens(bytes encodedRequest) internal virtual
Burns the ERC-721 or ERC-1155 tokens that were deposited by the user once the given request was opened.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | The encoded request for which the underlying tokens should be burnt. |
closeRequest
function closeRequest(bytes encodedRequest) external
Can only be called by the user, if the provider has not approved the given request yet. Closing a request will return the deposited phygital tokens back to the user who opened the request.
Closes an open request, before it has been approved by the provider.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | Encoded request whose beneficiary should be returned. |
acceptRequest
function acceptRequest(bytes32 requestId) external
Can only be called by the provider, if the user has not closed the request.
Accepts an open request.
Name | Type | Description |
---|---|---|
requestId | bytes32 | ID of the request being approved. |
rejectRequest
function rejectRequest(bytes encodedRequest, bytes rejectionReason) external
Can only be called by the provider, if the user has not closed the request and if the provider has not accepted the request. Rejecting a request will return the deposited phygital tokens back to the user who opened the request.
Rejects an open request.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | Encoded request whose beneficiary should be returned. |
rejectionReason | bytes | Reason for rejecting the request. |
fulfillRequest
function fulfillRequest(bytes encodedRequest, bytes trackingInfo, string customTokenURI) external
Can only be called by the provider. This can be even after a request's expiry period has passed if the user has not made a transaction to expire the request. Upon fulfillment, the user's phygital tokens are burnt and a unique, proof-of-redemption soulbound ERC-721 is minted to the user's address.
Fulfills an accepted request.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | Encoded request whose beneficiary should be returned. |
trackingInfo | bytes | Tracking information for the fulfilled request. |
customTokenURI | string | Custom token metadata URI for tokenID. Empty string if default is to be used. |
expireRequest
function expireRequest(bytes encodedRequest) external
Can only be called by the given request's owner, if the request has expired. Upon manual expiration, the phygital tokens that were deposited by the user are returned.
Expires an accepted request, and transfers the tokens back to the user.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | Encoded request whose beneficiary should be returned. |
pause
function pause() external
Pauses the creation, acceptance, and fulfillment of new requests for this Phygital Redeemer.
unpause
function unpause() external
Unpauses the creation, acceptance, and fulfillment of new requests for this Phygital Redeemer.
tokenURI
function tokenURI(uint256 tokenId) public view returns (string)
Returns the proof-of-redemption token's metadata URI.
setBaseTokenURI
function setBaseTokenURI(string baseTokenURI_) external
Sets the base URI for the proof-of-redemption
setRedemptionFee
function setRedemptionFee(address _token, uint256 _fee) external virtual
Vendor
Sets a redemption fee in an ERC20 token for a vendor.
Name | Type | Description |
---|---|---|
_token | address | Address of the ERC20 token |
_fee | uint256 | Redemption fee per singular NFT in payment token |
setRedemptionFeeNative
function setRedemptionFeeNative(uint256 _fee) external virtual
Vendor
Sets a redemption fee in native token for a vendor.
Name | Type | Description |
---|---|---|
_fee | uint256 | Redemption fee per singular NFT in native token |
setCustomRedemptionFeeMultipliers
function setCustomRedemptionFeeMultipliers(uint256[] _tokenIds, uint256[] _multipliers) external virtual
Vendor multiplier should assume 1x = 1,000,000 by default unless changed
Sets custom redemption fee multipliers for specific tokenIds for a vendor.
Name | Type | Description |
---|---|---|
_tokenIds | uint256[] | Array of tokenIds |
_multipliers | uint256[] | Array of multipliers |
setProtocolFeeAddress
function setProtocolFeeAddress(address _protocolFeeAddress) external
Owner only callable by the owner
Sets the protocol fee address for a redeemer.
Name | Type | Description |
---|---|---|
_protocolFeeAddress | address | address of the protocol fee contract |
setFeeProcessorAddress
function setFeeProcessorAddress(address _feeProcessorAddress) external
Owner only callable by the owner
Sets the fee processor address for a redeemer.
Name | Type | Description |
---|---|---|
_feeProcessorAddress | address | address of the fee processor contract |
payProtocolFeeUpfrontNative
function payProtocolFeeUpfrontNative() external payable
Vendor
Allows vendor to pay for the protocol fee upfront in native token.
payProtocolFeeUpfront
function payProtocolFeeUpfront(address paymentToken, uint256 amount) external
Vendor
Allows vendor to pay for the protocol fee upfront.
Name | Type | Description |
---|---|---|
paymentToken | address | address of the token |
amount | uint256 | amount to be paid upfront |
_transfer
function _transfer(address, address, uint256) internal pure
Overrides the ERC-721 _transfer function to always revert. This makes the proof-of-redemption ERC-721 token non-transferable.
_transferEscrowToRedeemer
function _transferEscrowToRedeemer(bytes encodedRequest) internal virtual
Utility function, transfers the escrowed payment to the redeemer.
_transferEscrow
function _transferEscrow(bytes32 requestId, address target) internal
Utility function, transfers the escrowed payment to the target * either user or vendor
handleERC20Payment
function handleERC20Payment(address from, address to, address paymentToken, uint256 amount) external
Utility -> called by FeeProcessor
Handles ERC20 transfers for payment.
Name | Type | Description |
---|---|---|
from | address | address from which the tokens are transferred |
to | address | address to which the tokens are transferred |
paymentToken | address | |
amount | uint256 | amount of tokens transferred |
handleProtocolFeePayment
function handleProtocolFeePayment(address paymentToken, uint256 amount) external
Utility -> called by FeeProcessor
Handles protocol fee ERC20 transfers to fee receiver.
Name | Type | Description |
---|---|---|
paymentToken | address | address of the token |
amount | uint256 | amount of tokens transferred |
handleNativePayment
function handleNativePayment(address target, uint256 amount) external
Utility -> called by FeeProcessor
Handles native token transfers for payment.
Name | Type | Description |
---|---|---|
target | address | address to which the tokens are transferred |
amount | uint256 | amount of tokens transferred |
getRedemptionFee
function getRedemptionFee(address paymentToken) external view returns (uint256)
Vendor
Returns the base redemption fee for a payment token * address(0) for base fee for native.
Name | Type | Description |
---|---|---|
paymentToken | address | address of the token |
Name | Type | Description |
---|---|---|
[0] | uint256 | redemptionFee redemption fee in payment token |
getPaymentInformation
function getPaymentInformation(uint256[] tokenIds, uint256[] amounts, enum IPhygitalRedeemerFeeProcessor.RedeemedTokenType redeemedTokenType) external view returns (struct IPhygitalRedeemerFeeProcessor.PaymentInformation)
User
Returns the payment information for a redemption request * returns all possible payment options.
Name | Type | Description |
---|---|---|
tokenIds | uint256[] | array of tokenIds to be redeemed |
amounts | uint256[] | array of amounts to be redeemed |
redeemedTokenType | enum IPhygitalRedeemerFeeProcessor.RedeemedTokenType |
Name | Type | Description |
---|---|---|
[0] | struct IPhygitalRedeemerFeeProcessor.PaymentInformation | paymentInformation payment information |
getCustomRedemptionFeeMultiplierForToken
function getCustomRedemptionFeeMultiplierForToken(uint256 tokenId) external view returns (uint256)
Vendor
returns the custom fee multiplier for a redeemable token.
Name | Type | Description |
---|---|---|
tokenId | uint256 | tokenId of the redeemable token |
Name | Type | Description |
---|---|---|
[0] | uint256 | customRedemptionFeeMultiplier custom redemption fee multiplier |
getEscrow
function getEscrow(bytes32 requestId) external view returns (struct IPhygitalRedeemerFeeProcessor.Escrow)
Vendor
Returns the escrow data for a redemption request.
Name | Type | Description |
---|---|---|
requestId | bytes32 | requestId of the redemption request |
Name | Type | Description |
---|---|---|
[0] | struct IPhygitalRedeemerFeeProcessor.Escrow | escrow Escrow data struct |
getBaseFees
function getBaseFees() external view returns (address[], uint256[], uint256[])
Vendor/Owner
Returns the base redemption and protocol fees for all payment tokens.
Name | Type | Description |
---|---|---|
[0] | address[] | paymentTokens array of payment tokens, address(0) for native |
[1] | uint256[] | redemptionFees array of redemption fees |
[2] | uint256[] | protocolFees array of protocol fees |
getVerifiedERC20PaymentTokens
function getVerifiedERC20PaymentTokens() external view returns (address[], uint256)
User/Vendor
returns a list of ERC20 tokens that are accepted by the protocol * and the vendor.
Name | Type | Description |
---|---|---|
[0] | address[] | verifiedPaymentTokens list of ERC20 tokens |
[1] | uint256 | verifiedLength how many tokens are in the list * verified list can be shorter if a vendor added a token that is no longer accepted, hence the length |
protocolAcceptsNative
function protocolAcceptsNative() external view returns (bool)
Vendor/Owner
Utility function, returns whether the protocol accepts native token for fee payment.
Name | Type | Description |
---|---|---|
[0] | bool | bool true if native token can be used for fee payments |
acceptedPaymentTokensByVendor
function acceptedPaymentTokensByVendor() external view returns (address[])
Vendor/Utility
Returns the list of ERC20 tokens accepted by the vendor.
calculateRequiredPayment
function calculateRequiredPayment(address paymentToken, uint256[] _tokenIds, uint256[] _amounts, enum IPhygitalRedeemerFeeProcessor.RedeemedTokenType redeemedRedeemedTokenType) external view returns (uint256 _redemptionFee, uint256 _protocolFee, uint256 _upfrontDiscount)
User For ERC721 _amounts can be empty array
Returns the total fees for a payment token based on the number and type of NFTs to be redeemed.
Name | Type | Description |
---|---|---|
paymentToken | address | address of the token |
_tokenIds | uint256[] | array of tokenIds to be redeemed |
_amounts | uint256[] | array of amounts to be redeemed |
redeemedRedeemedTokenType | enum IPhygitalRedeemerFeeProcessor.RedeemedTokenType | type of redeemed token |
Name | Type | Description |
---|---|---|
_redemptionFee | uint256 | redemption fee in payment token |
_protocolFee | uint256 | protocol fee in payment token |
_upfrontDiscount | uint256 | upfront discount in payment token |
redemptionFeeDivisor
function redemptionFeeDivisor() external view returns (uint256)
Vendor/Utility
Returns the redemption fee divisor.
PhygitalRedeemerFeeProcessor
Responsible for the management of redemption and protocol fees for a specific Redeemer instance.
protocolFeeAddress
address protocolFeeAddress
Address of the protocol fee contract.
registryAddress
address registryAddress
Address of the registry
redemptionFee
mapping(address => mapping(address => uint256)) redemptionFee
Maps redemption fee in payment token to value;
nativeRedemptionFee
mapping(address => uint256) nativeRedemptionFee
Redemption fee in native token
customRedemptionFeeMultiplier
mapping(address => mapping(uint256 => uint256)) customRedemptionFeeMultiplier
The multiplier determines that tokenIds redemption fee in relation to the base fee of that token
Maps vendor to tokenId to its custom redemption fee multiplier
redemptionFeeDivisor
mapping(address => uint256) redemptionFeeDivisor
The divisor determines the precision of the custom redemption fee multiplier is set to 1e18 upon initial customRedemptionFeeMultiplier setup
Custom vendor to redemption fee divisor
acceptedPaymentTokensByVendor
mapping(address => address[]) acceptedPaymentTokensByVendor
List of accepted ERC20 payment tokens by vendor
_isRedemptionFeePaymentRequired
mapping(address => bool) _isRedemptionFeePaymentRequired
Maps if vendor requires a redemption fee payment
_escrows
mapping(address => mapping(bytes32 => struct IPhygitalRedeemerFeeProcessor.Escrow)) _escrows
Maps vendor to requestId to escrow
onlyRedeemer
modifier onlyRedeemer()
constructor
constructor(address protocolFeeAddress_) public
handleRequestOpen
function handleRequestOpen(enum IPhygitalRedeemerFeeProcessor.RedeemedTokenType tokenType, bytes32 requestId, uint256[] tokenIds, uint256[] amounts, address paymentToken, address userAddress, uint256 msgValue) public
Utility
Handles the payment logic when a request is opened
Name | Type | Description |
---|---|---|
tokenType | enum IPhygitalRedeemerFeeProcessor.RedeemedTokenType | |
requestId | bytes32 | requestId of the redemption request |
tokenIds | uint256[] | array of tokenIds to be redeemed |
amounts | uint256[] | array of amounts to be redeemed |
paymentToken | address | address of the payment token * address(0) for native payments |
userAddress | address | address of the user * used to handle ERC20 payment logic |
msgValue | uint256 | value of the native payment |
getPaymentInformation
function getPaymentInformation(uint256[] tokenIds, uint256[] amounts, enum IPhygitalRedeemerFeeProcessor.RedeemedTokenType redeemedTokenType) public view returns (struct IPhygitalRedeemerFeeProcessor.PaymentInformation)
Utility -> called via Redeemer
Returns the payment information for a redemption request * returns all possible payment options
Name | Type | Description |
---|---|---|
tokenIds | uint256[] | array of tokenIds to be redeemed |
amounts | uint256[] | array of amounts to be redeemed |
redeemedTokenType | enum IPhygitalRedeemerFeeProcessor.RedeemedTokenType |
Name | Type | Description |
---|---|---|
[0] | struct IPhygitalRedeemerFeeProcessor.PaymentInformation | paymentInformation payment information |
getAcceptedPaymentTokensByVendor
function getAcceptedPaymentTokensByVendor() external view returns (address[])
Vendor/Utility -> called via Redeemer
Returns the list of ERC20 tokens accepted by the vendor
getBaseFees
function getBaseFees() external view returns (address[], uint256[], uint256[])
Vendor/Owner -> called via Redeemer
Returns the base redemption and protocol fees for all payment tokens
Name | Type | Description |
---|---|---|
[0] | address[] | paymentTokens array of payment tokens, address(0) for native |
[1] | uint256[] | redemptionFees array of redemption fees |
[2] | uint256[] | protocolFees array of protocol fees |
calculateRequiredPayment
function calculateRequiredPayment(address paymentToken, uint256[] _tokenIds, uint256[] amounts, enum IPhygitalRedeemerFeeProcessor.RedeemedTokenType redeemedRedeemedTokenType) public view returns (uint256 _redemptionFee, uint256 _protocolFee, uint256 _upfrontDiscount)
User/Utility -> called via Redeemer For ERC721 _amounts can be empty array
Returns the total fees for a payment token based on the number and type of NFTs to be redeemed
Name | Type | Description |
---|---|---|
paymentToken | address | address of the token |
_tokenIds | uint256[] | array of tokenIds to be redeemed |
amounts | uint256[] | |
redeemedRedeemedTokenType | enum IPhygitalRedeemerFeeProcessor.RedeemedTokenType | type of redeemed token |
Name | Type | Description |
---|---|---|
_redemptionFee | uint256 | redemption fee in payment token |
_protocolFee | uint256 | protocol fee in payment token |
_upfrontDiscount | uint256 | upfront discount in payment token |
getVerifiedERC20PaymentTokens
function getVerifiedERC20PaymentTokens() public view returns (address[], uint256)
Vendor/Utility -> called via Redeemer
returns a list of ERC20 tokens that are accepted by the protocol * and the vendor -> called via Redeemer
Name | Type | Description |
---|---|---|
[0] | address[] | verifiedPaymentTokens list of ERC20 tokens |
[1] | uint256 | verifiedLength how many tokens are in the list * verified list can be shorter if a vendor added a token that is no longer accepted, hence the length |
getEscrow
function getEscrow(bytes32 requestId) public view returns (struct IPhygitalRedeemerFeeProcessor.Escrow)
Vendor/Utility -> called via Redeemer
Returns the escrow data for a redemption request
Name | Type | Description |
---|---|---|
requestId | bytes32 | requestId of the redemption request |
Name | Type | Description |
---|---|---|
[0] | struct IPhygitalRedeemerFeeProcessor.Escrow | escrow Escrow data struct |
getCustomRedemptionFeeMultiplierForToken
function getCustomRedemptionFeeMultiplierForToken(uint256 tokenId) external view returns (uint256)
Vendor -> called via Redeemer
Returns the custom redemption fee multiplier for a token
Name | Type | Description |
---|---|---|
tokenId | uint256 | tokenId to check |
Name | Type | Description |
---|---|---|
[0] | uint256 | multiplier multiplier for the token |
getRedemptionFee
function getRedemptionFee(address paymentToken) external view returns (uint256)
Vendor/Utility -> called via Redeemer
Returns the base redemption fee for a payment token
Name | Type | Description |
---|---|---|
paymentToken | address | payment token address, address(0) for native or ERC20 |
Name | Type | Description |
---|---|---|
[0] | uint256 | fee redemption fee per singular NFT in payment token |
setRedemptionFee
function setRedemptionFee(address _token, uint256 _fee) public
Vendor -> called via Redeemer
Sets a redemption fee in an ERC20 token for a vendor
Name | Type | Description |
---|---|---|
_token | address | Address of the ERC20 token |
_fee | uint256 | Redemption fee per singular NFT in payment token |
setRedemptionFeeNative
function setRedemptionFeeNative(uint256 _fee) public
Vendor -> called via Redeemer
Sets a redemption fee in native token for a vendor
Name | Type | Description |
---|---|---|
_fee | uint256 | Redemption fee per singular NFT in native token |
setCustomRedemptionFeeMultipliers
function setCustomRedemptionFeeMultipliers(uint256[] _tokenIds, uint256[] _multipliers) public
Vendor -> called via Redeemer multiplier should assume 1x = 1,000,000 by default unless changed
Sets custom redemption fee multipliers for specific tokenIds for a vendor
Name | Type | Description |
---|---|---|
_tokenIds | uint256[] | Array of tokenIds |
_multipliers | uint256[] | Array of multipliers |
setProtocolFeeAddress
function setProtocolFeeAddress(address protocolFeeAddress_) external
Owner Can only be called by the owner.
Sets the address of the protocol fee contract.
Name | Type | Description |
---|---|---|
protocolFeeAddress_ | address |
setRegistryAddress
function setRegistryAddress(address registryAddress_) external
Owner Can only be called by the owner.
Sets the address of the registry contract.
Name | Type | Description |
---|---|---|
registryAddress_ | address |
_handleFeesNative
function _handleFeesNative(bytes32 requestId, uint256 _redemptionFee, uint256 protocolFee, address userAddress, uint256 msgValue) internal
handler of native fee payments
_handleFees
function _handleFees(bytes32 requestId, uint256 _redemptionFee, uint256 protocolFee, address paymentToken, address userAddress) internal
handler of ERC20 fee payments
_calculateRequiredPaymentERC721
function _calculateRequiredPaymentERC721(address paymentToken, uint256 baseRedemptionFee, uint256[] _tokenIds, uint256[]) internal view returns (uint256 _redemptionFee, uint256 _protocolFee, uint256 _upfrontDiscount)
helper function to calculate required payment for ERC20/native payments
Name | Type | Description |
---|---|---|
paymentToken | address | payment token, address(0) for native or ERC20 |
baseRedemptionFee | uint256 | base redemption fee value, either native or ERC20 |
_tokenIds | uint256[] | tokenIds of the tokens to be redeemed |
uint256[] |
Name | Type | Description |
---|---|---|
_redemptionFee | uint256 | redemption fee in payment token |
_protocolFee | uint256 | protocol fee in payment token |
_upfrontDiscount | uint256 | upfront discount in payment token |
_calculateRequiredPaymentERC1155
function _calculateRequiredPaymentERC1155(address paymentToken, uint256 baseRedemptionFee, uint256[] _tokenIds, uint256[] _amounts) internal view returns (uint256 _redemptionFee, uint256 _protocolFee, uint256 _upfrontDiscount)
helper function to calculate required payment for ERC20/native payments
Name | Type | Description |
---|---|---|
paymentToken | address | payment token, address(0) for native or ERC20 |
baseRedemptionFee | uint256 | base redemption fee value, either native or ERC20 |
_tokenIds | uint256[] | tokenIds of the tokens to be redeemed |
_amounts | uint256[] | amounts of the tokens to be redeemed |
Name | Type | Description |
---|---|---|
_redemptionFee | uint256 | redemption fee in payment token |
_protocolFee | uint256 | protocol fee in payment token |
_upfrontDiscount | uint256 | upfront discount in payment token |
_handleFeeVerificationNative
function _handleFeeVerificationNative() internal view returns (bool)
Ensures the payment method for a redemption is valid
_handleFeeVerification
function _handleFeeVerification(address paymentToken) internal view returns (bool)
_updateIfRedemptionPaymentRequired
function _updateIfRedemptionPaymentRequired() internal
utility function to help track if a vendor requires payment
_vendorAcceptsToken
function _vendorAcceptsToken(address token) internal view returns (bool)
Returns true if vendor accepts an ERC20 token as payment
Name | Type | Description |
---|---|---|
token | address | address of the token |
Name | Type | Description |
---|---|---|
[0] | bool | bool true if vendor accepts the token |
_verifyIfProtocolAcceptsNativeToken
function _verifyIfProtocolAcceptsNativeToken() internal view returns (bool)
verifies if native payments are acceptable by the protocol native payments must be set to be useable for protocol and redemption fees
Name | Type | Description |
---|---|---|
[0] | bool | acceptable returns if native token is acceptable for payments |
_verifyIfProtocolAcceptsERC20Token
function _verifyIfProtocolAcceptsERC20Token(address paymentToken) internal view returns (bool)
verifies if ERC20 token is accepted as payment by the protocol the token must be in the whitelist to be acceptable by both protocol and redemption fees
Name | Type | Description |
---|---|---|
paymentToken | address | chosen ERC20 payment token |
Name | Type | Description |
---|---|---|
[0] | bool | acceptable returns if the token is acceptable for payments |
PhygitalRedeemerRegistry
Responsible for administering PhygitalRedeemer instances.
protocolFeeAddress
address protocolFeeAddress
Address of the protocol fee contract.
feeProcessorAddress
address feeProcessorAddress
Address of the fee processor contract.
redeemers
struct IPhygitalRedeemerRegistry.RedeemerInfo[] redeemers
Array of all the exisiting Redeemer instances.
isRedeemer
mapping(address => bool) isRedeemer
Maps address to a boolean indicating whether or not the address is a Redeemer instance.
tokenToRedeemers
mapping(address => uint256[]) tokenToRedeemers
Maps ERC-721 or ERC-1155 token addresses to all of their associated redeemer indexes.
providerToRedeemers
mapping(address => uint256[]) providerToRedeemers
Maps provider addresses to all of their associated redeemer indexes.
constructor
constructor(address _protocolFeeAddress, address _feeProcessorAddress) public
getRedeemers
function getRedeemers() external view returns (struct IPhygitalRedeemerRegistry.RedeemerInfo[])
Returns the addresses of all Phygital Redeemer instances.
Name | Type | Description |
---|---|---|
[0] | struct IPhygitalRedeemerRegistry.RedeemerInfo[] |
getRedeemersForToken
function getRedeemersForToken(address token) external view returns (struct IPhygitalRedeemerRegistry.RedeemerInfo[] _redeemers)
Returns the addresses of Phygital Redeemer instances associated to a given phygital token address.
Name | Type | Description |
---|---|---|
token | address | Address of the phygital token. |
Name | Type | Description |
---|---|---|
_redeemers | struct IPhygitalRedeemerRegistry.RedeemerInfo[] |
getRedeemersForProvider
function getRedeemersForProvider(address provider) external view returns (struct IPhygitalRedeemerRegistry.RedeemerInfo[] _redeemers)
Returns the addresses of Phygital Redeemer instances associated to a given provider.
Name | Type | Description |
---|---|---|
provider | address | Address of the physical items' provider. |
Name | Type | Description |
---|---|---|
_redeemers | struct IPhygitalRedeemerRegistry.RedeemerInfo[] |
registerRedeemer
function registerRedeemer(address redeemer, address token, address provider, enum IPhygitalRedeemerRegistry.TokenType tokenType, address openRequestHooks) external
Can only be called by the regsitry owner.
Registers new Phygital Redeemer instance.
Name | Type | Description |
---|---|---|
redeemer | address | Address of the new Phygital Redeemer to register. |
token | address | Address of the phygital token that can |
provider | address | Address of the physical items' provider. |
tokenType | enum IPhygitalRedeemerRegistry.TokenType | Type of phygital token. |
openRequestHooks | address | Address to call on request opening. Can be set to address(0) to ignore the hook |
pauseRedeemer
function pauseRedeemer(address redeemer) external
Can only be called by the registry owner.
Pauses Phygital Redeemer instance.
Name | Type | Description |
---|---|---|
redeemer | address | Address of the Redeemer instance to pause. |
unpauseRedeemer
function unpauseRedeemer(address redeemer) external
Can only be called by the registry owner.
Unpauses Phygital Redeemer instance.
Name | Type | Description |
---|---|---|
redeemer | address | Address of the Redeemer instance to unpause. |
_setProtocolFeeAddress
function _setProtocolFeeAddress(address _protocolFeeAddress) internal
It only updates the maximum fulfillment duration for Redeemer instances that are created thereafter.
Internal function that sets the address of the protocol fee contract.
Name | Type | Description |
---|---|---|
_protocolFeeAddress | address | Address of the protocol fee contract. |
setProtocolFeeAddress
function setProtocolFeeAddress(address _protocolFeeAddress) external
Can only be called by the factory owner. It only updates the maximum fulfillment duration for Redeemer instances that are created thereafter.
Sets the address of the protocol fee contract.
Name | Type | Description |
---|---|---|
_protocolFeeAddress | address | Address of the protocol fee contract. |
_setFeeProcessorAddress
function _setFeeProcessorAddress(address _feeProcessorAddress) internal
It only updates the maximum fulfillment duration for Redeemer instances that are created thereafter.
Internal function that sets the address of the fee processor contract.
Name | Type | Description |
---|---|---|
_feeProcessorAddress | address | Address of the fee processor contract. |
setFeeProcessorAddress
function setFeeProcessorAddress(address _feeProcessorAddress) external
Can only be called by the factory owner. It only updates the maximum fulfillment duration for Redeemer instances that are created thereafter.
Sets the address of the fee processor contract.
Name | Type | Description |
---|---|---|
_feeProcessorAddress | address | Address of the fee processor contract. |
batchUpdateProtocolAddress
function batchUpdateProtocolAddress(address _protocolFeeAddress) external
Updates protocol address across all redeemers.
Name | Type | Description |
---|---|---|
_protocolFeeAddress | address | Address of the protocol fee contract. |
batchUpdateFeeProcessorAddress
function batchUpdateFeeProcessorAddress(address _feeProcessorAddress) external
Updates fee processor address across all redeemers.
Name | Type | Description |
---|---|---|
_feeProcessorAddress | address | Address of the fee processor contract. |
ProtocolFee
Responsible for the management of protocol fees across all Redeemer instances.
registryAddress
address registryAddress
Address of the registry
protocolFeeReceiver
address protocolFeeReceiver
Address to which protocol fees will be sent
generalNativeProtocolFee
uint256 generalNativeProtocolFee
Base native protocol fee
generalERC20ProtocolFees
mapping(address => uint256) generalERC20ProtocolFees
Base protocol fee for accepted ERC20 tokens
protocolFeeTiers
struct IProtocolFee.FeeTier[] protocolFeeTiers
The tiers should be in ascending order
Holds the different protocol fee tiers
feeDivisor
uint256 feeDivisor
Divisor for fee precision
tierDivisor
uint256 tierDivisor
Divisor for tier precision
upfrontPaymentPrecision
uint256 upfrontPaymentPrecision
Divisor for upfront payment precision
_whitelistedTokensForPayment
address[] _whitelistedTokensForPayment
List of whitelisted ERC20 tokens which can be used in both redemptions and protocol payments
protocolFeePaid
mapping(address => uint256) protocolFeePaid
The remaining fees are stored as a multiplier * of either ERC20 or native protocol fee
Maps redeemer to protocol fee paid upfront by vendor
onlyFeeProcessor
modifier onlyFeeProcessor()
constructor
constructor(address protocolFeeReceiver_) public
protocolAcceptsNative
function protocolAcceptsNative() public view returns (bool)
Vendor/Owner
Utility function, returns whether the protocol accepts native token for fee payment.
Name | Type | Description |
---|---|---|
[0] | bool | bool true if native token can be used for fee payments |
protocolAcceptsToken
function protocolAcceptsToken(address paymentToken) public view returns (bool)
Utility
Utility function, returns whether the protocol accepts a given ERC20 token. for fee payment
Name | Type | Description |
---|---|---|
paymentToken | address | chosen ERC20 payment token |
Name | Type | Description |
---|---|---|
[0] | bool | bool true if token can be used for fee payments |
isProtocolFeePaymentRequired
function isProtocolFeePaymentRequired() external view returns (bool)
Utility
Utility function, returns whether the protocol requires a fee payment.
Name | Type | Description |
---|---|---|
[0] | bool | bool true if protocol requires a fee payment |
getTokensAcceptedByProtocol
function getTokensAcceptedByProtocol() external view returns (address[])
Vendor/Owner
Getter for ERC20 tokens accepted by the protocol.
Name | Type | Description |
---|---|---|
[0] | address[] | tokensAcceptedByProtocol array of ERC20 tokens accepted by the protocol |
calculateProtocolFee
function calculateProtocolFee(address paymentToken, uint256 redemptionFee) external view returns (uint256)
Utility
Returns the total protocol fee payed in an ERC20/Native token * based on the protocol fee tiers and the due redemption fee.
Name | Type | Description |
---|---|---|
paymentToken | address | payment token, either ERC20 or address(0) for native |
redemptionFee | uint256 | redemption fee which will be paid |
Name | Type | Description |
---|---|---|
[0] | uint256 | fee protocol fee in payment token |
setRegistryAddress
function setRegistryAddress(address registryAddress_) external
Owner Can only be called by the owner.
Sets the address of the registry contract.
Name | Type | Description |
---|---|---|
registryAddress_ | address |
setProtocolFeeNative
function setProtocolFeeNative(uint256 nativeProtocolFee_) external
Owner
Setter for base protocol fee in native token.
Name | Type | Description |
---|---|---|
nativeProtocolFee_ | uint256 |
setProtocolFee
function setProtocolFee(address tokenAddress, uint256 protocolFee_) external
Owner
Setter for base protocol fee in ERC20 token.
Name | Type | Description |
---|---|---|
tokenAddress | address | |
protocolFee_ | uint256 |
setProtocolFeeReceiver
function setProtocolFeeReceiver(address protocolFeeReceiver_) external
Owner
Setter for address to which protocol fees will be sent.
Name | Type | Description |
---|---|---|
protocolFeeReceiver_ | address |
setProtocolFeeTiers
function setProtocolFeeTiers(struct IProtocolFee.FeeTier[] _protocolFeeTiers) external
Owner
Setter for protocol fee tiers * determines if an extra fee should be added to the redemption fee.
Name | Type | Description |
---|---|---|
_protocolFeeTiers | struct IProtocolFee.FeeTier[] | protocol fee tiers * should be in ascending order |
payProtocolFeeUpfrontNative
function payProtocolFeeUpfrontNative(uint256 amount) external
Utility - called via Redeemer
Allows a vendor to pay for a protocol fee upfront in native token.
Name | Type | Description |
---|---|---|
amount | uint256 | amount to be paid upfront |
payProtocolFeeUpfront
function payProtocolFeeUpfront(address paymentToken, uint256 amount) external
Utility - called via Redeemer
Allows a vendor to pay for a protocol fee upfront in ERC20 token.
Name | Type | Description |
---|---|---|
paymentToken | address | address of the payment token |
amount | uint256 | amount to be paid upfront |
calculateUpfrontDiscount
function calculateUpfrontDiscount(address vendorOrigin, address paymentToken, uint256 protocolFee) external view returns (uint256)
Utility
Calculates how much upfront discount a user should receive, * based on the outstanding protocol fee paid by the vendor.
Name | Type | Description |
---|---|---|
vendorOrigin | address | address of the vendor |
paymentToken | address | payment token, either address(0) for native or ERC20 |
protocolFee | uint256 | protocol fee to be paid |
Name | Type | Description |
---|---|---|
[0] | uint256 | upfrontDiscount amount of upfront discount |
handleUpfrontDiscount
function handleUpfrontDiscount(address vendorOrigin, address paymentToken, uint256 protocolFeeToBePaid) external
Utility
Allows the protocol to handle upfront discount * reduces the outstanding protocol fee paid by the vendor.
Name | Type | Description |
---|---|---|
vendorOrigin | address | address of the vendor |
paymentToken | address | payment token, either address(0) for native or ERC20 |
protocolFeeToBePaid | uint256 |
_isInTierRange
function _isInTierRange(uint256 baseProtocolFee, uint256 redemptionFee, uint256 tier) internal view returns (bool)
Checks if the redemption fee is in the range of a given tier
Name | Type | Description |
---|---|---|
baseProtocolFee | uint256 | base protocol fee value, either native or ERC20 |
redemptionFee | uint256 | redemption fee value |
tier | uint256 | tier whose range will be checked |
Name | Type | Description |
---|---|---|
[0] | bool | bool true if the redemption fee is in the range of the tier |
_removeTokenFromPaymentWhitelist
function _removeTokenFromPaymentWhitelist(address tokenAddress) internal
Removes a token from the whitelist
Name | Type | Description |
---|---|---|
tokenAddress | address | address of the token to be removed |
IERC1155Burnable
burn
function burn(address account, uint256[] ids, uint256[] values) external
Burns a given batch of tokens
Name | Type | Description |
---|---|---|
account | address | Token holder's account address. |
ids | uint256[] | Array of IDs of the tokens to be burnt. |
values | uint256[] | Array of amounts of tokens to be burnt. |
IERC721Burnable
burn
function burn(uint256 tokenId) external
Burns the given token.
Name | Type | Description |
---|---|---|
tokenId | uint256 | Token ID to burn. |
IFeeHelper
CallerNotFeeProcessor
error CallerNotFeeProcessor()
Thrown when the caller is not the fee processor.
CannotBeZeroAddress
error CannotBeZeroAddress()
Thrown when the zero address is passed.
payProtocolFeeUpfrontNative
function payProtocolFeeUpfrontNative() external payable
Vendor
Allows vendor to pay for the protocol fee upfront in native token.
payProtocolFeeUpfront
function payProtocolFeeUpfront(address paymentToken, uint256 amount) external
Vendor
Allows vendor to pay for the protocol fee upfront.
Name | Type | Description |
---|---|---|
paymentToken | address | address of the token |
amount | uint256 | amount to be paid upfront |
getRedemptionFee
function getRedemptionFee(address paymentToken) external view returns (uint256)
Vendor
Returns the base redemption fee for a payment token * address(0) for base fee for native.
Name | Type | Description |
---|---|---|
paymentToken | address | address of the token |
Name | Type | Description |
---|---|---|
[0] | uint256 | redemptionFee redemption fee in payment token |
getCustomRedemptionFeeMultiplierForToken
function getCustomRedemptionFeeMultiplierForToken(uint256 tokenId) external view returns (uint256)
Vendor
returns the custom fee multiplier for a redeemable token.
Name | Type | Description |
---|---|---|
tokenId | uint256 | tokenId of the redeemable token |
Name | Type | Description |
---|---|---|
[0] | uint256 | customRedemptionFeeMultiplier custom redemption fee multiplier |
getEscrow
function getEscrow(bytes32 requestId) external view returns (struct IPhygitalRedeemerFeeProcessor.Escrow)
Vendor
Returns the escrow data for a redemption request.
Name | Type | Description |
---|---|---|
requestId | bytes32 | requestId of the redemption request |
Name | Type | Description |
---|---|---|
[0] | struct IPhygitalRedeemerFeeProcessor.Escrow | escrow Escrow data struct |
setRedemptionFee
function setRedemptionFee(address _token, uint256 _fee) external
Vendor
Sets a redemption fee in an ERC20 token for a vendor.
Name | Type | Description |
---|---|---|
_token | address | Address of the ERC20 token |
_fee | uint256 | Redemption fee per singular NFT in payment token |
setRedemptionFeeNative
function setRedemptionFeeNative(uint256 _fee) external
Vendor
Sets a redemption fee in native token for a vendor.
Name | Type | Description |
---|---|---|
_fee | uint256 | Redemption fee per singular NFT in native token |
setCustomRedemptionFeeMultipliers
function setCustomRedemptionFeeMultipliers(uint256[] _tokenIds, uint256[] _multipliers) external
Vendor multiplier should assume 1x = 1,000,000 by default unless changed
Sets custom redemption fee multipliers for specific tokenIds for a vendor.
Name | Type | Description |
---|---|---|
_tokenIds | uint256[] | Array of tokenIds |
_multipliers | uint256[] | Array of multipliers |
redemptionFeeDivisor
function redemptionFeeDivisor() external view returns (uint256)
Vendor/Utility
Returns the redemption fee divisor.
getVerifiedERC20PaymentTokens
function getVerifiedERC20PaymentTokens() external view returns (address[], uint256)
User/Vendor
returns a list of ERC20 tokens that are accepted by the protocol * and the vendor.
Name | Type | Description |
---|---|---|
[0] | address[] | verifiedPaymentTokens list of ERC20 tokens |
[1] | uint256 | verifiedLength how many tokens are in the list * verified list can be shorter if a vendor added a token that is no longer accepted, hence the length |
acceptedPaymentTokensByVendor
function acceptedPaymentTokensByVendor() external view returns (address[])
Vendor/Utility
Returns the list of ERC20 tokens accepted by the vendor.
getPaymentInformation
function getPaymentInformation(uint256[] tokenIds, uint256[] amounts, enum IPhygitalRedeemerFeeProcessor.RedeemedTokenType redeemedTokenType) external view returns (struct IPhygitalRedeemerFeeProcessor.PaymentInformation)
User
Returns the payment information for a redemption request * returns all possible payment options.
Name | Type | Description |
---|---|---|
tokenIds | uint256[] | array of tokenIds to be redeemed |
amounts | uint256[] | array of amounts to be redeemed |
redeemedTokenType | enum IPhygitalRedeemerFeeProcessor.RedeemedTokenType |
Name | Type | Description |
---|---|---|
[0] | struct IPhygitalRedeemerFeeProcessor.PaymentInformation | paymentInformation payment information |
getBaseFees
function getBaseFees() external view returns (address[], uint256[], uint256[])
Vendor/Owner
Returns the base redemption and protocol fees for all payment tokens.
Name | Type | Description |
---|---|---|
[0] | address[] | paymentTokens array of payment tokens, address(0) for native |
[1] | uint256[] | redemptionFees array of redemption fees |
[2] | uint256[] | protocolFees array of protocol fees |
calculateRequiredPayment
function calculateRequiredPayment(address paymentToken, uint256[] _tokenIds, uint256[] _amounts, enum IPhygitalRedeemerFeeProcessor.RedeemedTokenType redeemedRedeemedTokenType) external view returns (uint256 _redemptionFee, uint256 _protocolFee, uint256 _upfrontDiscount)
User For ERC721 _amounts can be empty array
Returns the total fees for a payment token based on the number and type of NFTs to be redeemed.
Name | Type | Description |
---|---|---|
paymentToken | address | address of the token |
_tokenIds | uint256[] | array of tokenIds to be redeemed |
_amounts | uint256[] | array of amounts to be redeemed |
redeemedRedeemedTokenType | enum IPhygitalRedeemerFeeProcessor.RedeemedTokenType | type of redeemed token |
Name | Type | Description |
---|---|---|
_redemptionFee | uint256 | redemption fee in payment token |
_protocolFee | uint256 | protocol fee in payment token |
_upfrontDiscount | uint256 | upfront discount in payment token |
setProtocolFeeAddress
function setProtocolFeeAddress(address _protocolFeeAddress) external
Owner only callable by the owner
Sets the protocol fee address for a redeemer.
Name | Type | Description |
---|---|---|
_protocolFeeAddress | address | address of the protocol fee contract |
setFeeProcessorAddress
function setFeeProcessorAddress(address _feeProcessorAddress) external
Owner only callable by the owner
Sets the fee processor address for a redeemer.
Name | Type | Description |
---|---|---|
_feeProcessorAddress | address | address of the fee processor contract |
protocolFeeAddress
function protocolFeeAddress() external returns (address)
Owner
Returns the set protocol fee address.
Name | Type | Description |
---|---|---|
[0] | address | protocolFeeAddress address of the protocol fee contract |
feeProcessorAddress
function feeProcessorAddress() external returns (address)
Owner
Returns the set fee processor address.
Name | Type | Description |
---|---|---|
[0] | address | feeProcessorAddress address of the fee processor contract |
handleERC20Payment
function handleERC20Payment(address from, address to, address token, uint256 amount) external
Utility -> called by FeeProcessor
Handles ERC20 transfers for payment.
Name | Type | Description |
---|---|---|
from | address | address from which the tokens are transferred |
to | address | address to which the tokens are transferred |
token | address | address of the token |
amount | uint256 | amount of tokens transferred |
handleNativePayment
function handleNativePayment(address target, uint256 amount) external
Utility -> called by FeeProcessor
Handles native token transfers for payment.
Name | Type | Description |
---|---|---|
target | address | address to which the tokens are transferred |
amount | uint256 | amount of tokens transferred |
handleProtocolFeePayment
function handleProtocolFeePayment(address paymentToken, uint256 amount) external
Utility -> called by FeeProcessor
Handles protocol fee ERC20 transfers to fee receiver.
Name | Type | Description |
---|---|---|
paymentToken | address | address of the token |
amount | uint256 | amount of tokens transferred |
protocolAcceptsNative
function protocolAcceptsNative() external view returns (bool)
Vendor/Owner
Utility function, returns whether the protocol accepts native token for fee payment.
Name | Type | Description |
---|---|---|
[0] | bool | bool true if native token can be used for fee payments |
IPhygitalRedeemer1155
Request1155
struct Request1155 {
bytes32 nonce;
address owner;
uint256[] tokenIds;
uint256[] amounts;
}
TokenAmountZero
error TokenAmountZero()
Thrown when the token amount is zero
openRequest
function openRequest(bytes32 publicKey, bytes32 nonce, uint256[] tokenIds, uint256[] amounts, bytes shippingAddress, address paymentToken) external payable returns (bytes32 requestId)
Opens a new request with ERC20 token used in redemption fee.
Name | Type | Description |
---|---|---|
publicKey | bytes32 | Public key of the redeemer. |
nonce | bytes32 | Unique nonce for the redemption request. |
tokenIds | uint256[] | Token IDs to redeem. |
amounts | uint256[] | Amounts of each token ID to redeem. |
shippingAddress | bytes | Encrypted shipping address. |
paymentToken | address | Address of the payment token, address(0) for native. |
Name | Type | Description |
---|---|---|
requestId | bytes32 | Unique ID for the opened request. |
IPhygitalRedeemer721
AlreadyRedeemed
error AlreadyRedeemed()
Thrown when a token is already redeemed
Request721
struct Request721 {
bytes32 nonce;
address owner;
uint256[] tokenIds;
}
BurnMechanism
enum BurnMechanism {
Default,
Burn,
Mark,
Reredeemable
}
openRequest
function openRequest(bytes32 publicKey, bytes32 nonce, uint256[] tokenIds, bytes shippingAddress, address paymentToken) external payable returns (bytes32 requestId)
Opens a new request with ERC20 token used in redemption fee
Name | Type | Description |
---|---|---|
publicKey | bytes32 | Public key of the redeemer. |
nonce | bytes32 | Unique nonce for the redemption request. |
tokenIds | uint256[] | Token IDs to be redeemed. |
shippingAddress | bytes | Encrypted shipping address. |
paymentToken | address | Address of the payment token, address(0) for native. |
Name | Type | Description |
---|---|---|
requestId | bytes32 | Unique ID for the opened request. |
setDefaultBurnMechanism
function setDefaultBurnMechanism(enum IPhygitalRedeemer721.BurnMechanism burnMechanism) external
Sets the default burn mechanism for the entire collection
Name | Type | Description |
---|---|---|
burnMechanism | enum IPhygitalRedeemer721.BurnMechanism | Redemption type which will be set for the token |
setBurnMechanismForToken
function setBurnMechanismForToken(uint256 tokenId, enum IPhygitalRedeemer721.BurnMechanism burnMechanism) external
Sets if a redeemed ERC721 will be burned, marked as already redeemed or returned to owner
Name | Type | Description |
---|---|---|
tokenId | uint256 | Token ID to be redeemed |
burnMechanism | enum IPhygitalRedeemer721.BurnMechanism | Redemption type which will be set for the token |
setBurnMechanismForTokens
function setBurnMechanismForTokens(uint256[] tokenIds, enum IPhygitalRedeemer721.BurnMechanism burnMechanism) external
Sets the burn mechanism for a batch of tokens
Name | Type | Description |
---|---|---|
tokenIds | uint256[] | Token IDs to set redemption type for |
burnMechanism | enum IPhygitalRedeemer721.BurnMechanism | Redemption type which will be set for the token |
burnMechanism
function burnMechanism(uint256 tokenId) external view returns (enum IPhygitalRedeemer721.BurnMechanism)
Returns the custom burn mechanism for a given token
defaultBurnMechanism
function defaultBurnMechanism() external view returns (enum IPhygitalRedeemer721.BurnMechanism)
Returns the default burn mechanism for the collection
IPhygitalRedeemerCommon
Interface for functionality that applies to both ERC-721 and ERC-1155 Phygital Redeemers.
RequestStatus
enum RequestStatus {
NULL,
OPENED,
CLOSED,
ACCEPTED,
REJECTED,
FULFILLED,
EXPIRED
}
RequestState
struct RequestState {
enum IPhygitalRedeemerCommon.RequestStatus status;
uint256 expiry;
}
RequestStatusUpdate
event RequestStatusUpdate(bytes32 requestId, enum IPhygitalRedeemerCommon.RequestStatus updatedStatus)
Emitted when a request status gets updated.
Name | Type | Description |
---|---|---|
requestId | bytes32 | ID associated to the request. |
updatedStatus | enum IPhygitalRedeemerCommon.RequestStatus | Updated request status. |
StartIdOutOfBound
error StartIdOutOfBound()
Thrown when the start ID exceeds the number of requests.
InvalidRequestStatus
error InvalidRequestStatus(enum IPhygitalRedeemerCommon.RequestStatus expected, enum IPhygitalRedeemerCommon.RequestStatus actual)
Thrown when the request is in an unexpected status.
Name | Type | Description |
---|---|---|
expected | enum IPhygitalRedeemerCommon.RequestStatus | Expected request status. |
actual | enum IPhygitalRedeemerCommon.RequestStatus | Actual request status. |
CallerNotProvider
error CallerNotProvider()
Thrown when the caller is expected to be the provider, but is not.
CallerNotRequestOwner
error CallerNotRequestOwner()
Thrown when the caller is expected to be the request owner, but is not.
RequestNotExpired
error RequestNotExpired()
Thrown when the request is expected to have expired, but it has not.
SoulboundTokenCannotBeTransferred
error SoulboundTokenCannotBeTransferred()
Thrown when the user attempts to transfer the proof-of-redemption soulbound token.
ContractPaused
error ContractPaused()
Thrown when an operation is performed on a paused Phygital Redeemer contract.
EmptyTokenList
error EmptyTokenList()
Thrown when the request is opened with an empty ERC-721 or ERC-1155 token list.
TokensAmountsMismatch
error TokensAmountsMismatch()
Thrown when the size of the token list does not match the size of the amounts.
InvalidRequest
error InvalidRequest()
Thrown when the provided request does not match the given request ID.
token
function token() external view returns (address token)
Returns the address of the phygital token that can be redeemed.
Name | Type | Description |
---|---|---|
token | address | Phygital token's address. |
provider
function provider() external view returns (address provider)
Returns the physical item provider's address.
Name | Type | Description |
---|---|---|
provider | address | Physical item provider's address. |
providerPublicKey
function providerPublicKey() external view returns (bytes32 providerPublicKey)
Returns the physical item provider's public key.
Name | Type | Description |
---|---|---|
providerPublicKey | bytes32 | Physical item provider's public key. |
maxFulfillmentDuration
function maxFulfillmentDuration() external view returns (uint256 duration)
Returns the maximum allowed fulfillment duration.
Name | Type | Description |
---|---|---|
duration | uint256 | Duration, denominated in seconds. |
openRequestHooks
function openRequestHooks() external view returns (address hook)
Returns the address of the contract that implements the hook(s) that will be called when opening a new redemption request. If the address is the zero address, then no hooks are called.
paused
function paused() external view returns (bool paused)
Returns whether the contract has been paused.
Name | Type | Description |
---|---|---|
paused | bool | True if the contract is paused, false otherwise. |
getRequestState
function getRequestState(bytes32 requestId) external view returns (struct IPhygitalRedeemerCommon.RequestState state)
Returns the given request's state.
Name | Type | Description |
---|---|---|
requestId | bytes32 | ID of the request whose state to return. |
Name | Type | Description |
---|---|---|
state | struct IPhygitalRedeemerCommon.RequestState | State associated to the given request. |
getRequestBeneficiary
function getRequestBeneficiary(bytes encodedRequest) external view returns (address beneficiary)
Returns the beneficiary of the soulbound token.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | Encoded request whose beneficiary should be returned. |
Name | Type | Description |
---|---|---|
beneficiary | address | Owner of the given request. |
closeRequest
function closeRequest(bytes encodedRequest) external
Can only be called by the user, if the provider has not approved the given request yet. Closing a request will return the deposited phygital tokens back to the user who opened the request.
Closes an open request, before it has been approved by the provider.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | Encoded request whose beneficiary should be returned. |
acceptRequest
function acceptRequest(bytes32 requestId) external
Can only be called by the provider, if the user has not closed the request.
Accepts an open request.
Name | Type | Description |
---|---|---|
requestId | bytes32 | ID of the request being approved. |
rejectRequest
function rejectRequest(bytes encodedRequest, bytes rejectionReason) external
Can only be called by the provider, if the user has not closed the request and if the provider has not accepted the request. Rejecting a request will return the deposited phygital tokens back to the user who opened the request.
Rejects an open request.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | Encoded request whose beneficiary should be returned. |
rejectionReason | bytes | Reason for rejecting the request. |
fulfillRequest
function fulfillRequest(bytes encodedRequest, bytes trackingInfo, string customTokenURI) external
Can only be called by the provider. This can be even after a request's expiry period has passed if the user has not made a transaction to expire the request. Upon fulfillment, the user's phygital tokens are burnt and a unique, proof-of-redemption soulbound ERC-721 is minted to the user's address.
Fulfills an accepted request.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | Encoded request whose beneficiary should be returned. |
trackingInfo | bytes | Tracking information for the fulfilled request. |
customTokenURI | string | Custom token metadata URI for tokenID. Empty string if default is to be used. |
expireRequest
function expireRequest(bytes encodedRequest) external
Can only be called by the given request's owner, if the request has expired. Upon manual expiration, the phygital tokens that were deposited by the user are returned.
Expires an accepted request, and transfers the tokens back to the user.
Name | Type | Description |
---|---|---|
encodedRequest | bytes | Encoded request whose beneficiary should be returned. |
pause
function pause() external
Pauses the creation, acceptance, and fulfillment of new requests for this Phygital Redeemer.
unpause
function unpause() external
Unpauses the creation, acceptance, and fulfillment of new requests for this Phygital Redeemer.
setBaseTokenURI
function setBaseTokenURI(string baseTokenURI_) external
Sets the base URI for the proof-of-redemption
IPhygitalRedeemerFeeProcessor
RedeemedTokenType
enum RedeemedTokenType {
ERC721,
ERC1155
}
EscrowType
enum EscrowType {
NULL,
ERC20,
NATIVE
}
Escrow
struct Escrow {
enum IPhygitalRedeemerFeeProcessor.EscrowType escrowType;
address token;
uint256 amount;
}
CallerNotRedeemer
error CallerNotRedeemer()
Emitted when the caller is not a Redeemer instance.
InsufficientPayment
error InsufficientPayment()
Thrown when insufficient native token is sent.
TokenNotInPaymentWhitelist
error TokenNotInPaymentWhitelist()
Emitted when trying to use a token which is not in the protocol whitelist.
RedemptionFeeNativeNotAccepted
error RedemptionFeeNativeNotAccepted()
Emitted when native payments are not accepted.
RedemptionFeeTokenNotAccepted
error RedemptionFeeTokenNotAccepted()
Thrown when the payment token is not accepted.
TokensMultipliersMismatch
error TokensMultipliersMismatch()
Thrown when the size of the token list does not match the size of the custom redemption fee multipliers.
CannotBeZeroAddress
error CannotBeZeroAddress()
Thrown when the zero address is passed.
ProtocolTokenNotAccepted
error ProtocolTokenNotAccepted()
Thrown when the protocol does not accept an ERC20 token for fee payment.
ProtocolNativeNotAccepted
error ProtocolNativeNotAccepted()
Thrown when the protocol does not accept native token for fee payment.
IncorrectVendorPaymentSettings
error IncorrectVendorPaymentSettings()
Thrown when a vendor has set payments only in ERC20 tokens which are no longer accepted by the protocol the vendor still expects payment and should be informed that their settings are outdated.
TokensAmountsMismatch
error TokensAmountsMismatch()
Thrown when the size of the token list does not match the size of the amounts.
EmptyTokenList
error EmptyTokenList()
Thrown when the request is opened with an empty ERC-721 or ERC-1155 token list.
PaymentInformation
struct PaymentInformation {
bool isNativeAccepted;
uint256 nativeFee;
address[] acceptedPaymentTokens;
uint256[] erc20Fees;
bool isPaymentRequired;
}
setProtocolFeeAddress
function setProtocolFeeAddress(address protocolFeeContract_) external
Owner Can only be called by the owner.
Sets the address of the protocol fee contract.
Name | Type | Description |
---|---|---|
protocolFeeContract_ | address | Address of the protocol fee contract. |
setRegistryAddress
function setRegistryAddress(address registryContract_) external
Owner Can only be called by the owner.
Sets the address of the registry contract.
Name | Type | Description |
---|---|---|
registryContract_ | address | Address of the registry contract. |
calculateRequiredPayment
function calculateRequiredPayment(address paymentToken, uint256[] _tokenIds, uint256[] _amounts, enum IPhygitalRedeemerFeeProcessor.RedeemedTokenType redeemedRedeemedTokenType) external view returns (uint256 _redemptionFee, uint256 _protocolFee, uint256 _upfrontDiscount)
User/Utility -> called via Redeemer For ERC721 _amounts can be empty array
Returns the total fees for a payment token based on the number and type of NFTs to be redeemed
Name | Type | Description |
---|---|---|
paymentToken | address | address of the token |
_tokenIds | uint256[] | array of tokenIds to be redeemed |
_amounts | uint256[] | array of amounts to be redeemed |
redeemedRedeemedTokenType | enum IPhygitalRedeemerFeeProcessor.RedeemedTokenType | type of redeemed token |
Name | Type | Description |
---|---|---|
_redemptionFee | uint256 | redemption fee in payment token |
_protocolFee | uint256 | protocol fee in payment token |
_upfrontDiscount | uint256 | upfront discount in payment token |
getRedemptionFee
function getRedemptionFee(address paymentToken) external view returns (uint256)
Vendor/Utility -> called via Redeemer
Returns the base redemption fee for a payment token
Name | Type | Description |
---|---|---|
paymentToken | address | payment token address, address(0) for native or ERC20 |
Name | Type | Description |
---|---|---|
[0] | uint256 | fee redemption fee per singular NFT in payment token |
getEscrow
function getEscrow(bytes32 requestId) external view returns (struct IPhygitalRedeemerFeeProcessor.Escrow)
Vendor/Utility -> called via Redeemer
Returns the escrow data for a redemption request
Name | Type | Description |
---|---|---|
requestId | bytes32 | requestId of the redemption request |
Name | Type | Description |
---|---|---|
[0] | struct IPhygitalRedeemerFeeProcessor.Escrow | escrow Escrow data struct |
getVerifiedERC20PaymentTokens
function getVerifiedERC20PaymentTokens() external view returns (address[], uint256)
Vendor/Utility -> called via Redeemer
returns a list of ERC20 tokens that are accepted by the protocol * and the vendor -> called via Redeemer
Name | Type | Description |
---|---|---|
[0] | address[] | verifiedPaymentTokens list of ERC20 tokens |
[1] | uint256 | verifiedLength how many tokens are in the list * verified list can be shorter if a vendor added a token that is no longer accepted, hence the length |
getAcceptedPaymentTokensByVendor
function getAcceptedPaymentTokensByVendor() external view returns (address[])
Vendor/Utility -> called via Redeemer
Returns the list of ERC20 tokens accepted by the vendor
getBaseFees
function getBaseFees() external view returns (address[], uint256[], uint256[])
Vendor/Owner -> called via Redeemer
Returns the base redemption and protocol fees for all payment tokens
Name | Type | Description |
---|---|---|
[0] | address[] | paymentTokens array of payment tokens, address(0) for native |
[1] | uint256[] | redemptionFees array of redemption fees |
[2] | uint256[] | protocolFees array of protocol fees |
setRedemptionFee
function setRedemptionFee(address _token, uint256 _fee) external
Vendor -> called via Redeemer
Sets a redemption fee in an ERC20 token for a vendor
Name | Type | Description |
---|---|---|
_token | address | Address of the ERC20 token |
_fee | uint256 | Redemption fee per singular NFT in payment token |
setRedemptionFeeNative
function setRedemptionFeeNative(uint256 _fee) external
Vendor -> called via Redeemer
Sets a redemption fee in native token for a vendor
Name | Type | Description |
---|---|---|
_fee | uint256 | Redemption fee per singular NFT in native token |
setCustomRedemptionFeeMultipliers
function setCustomRedemptionFeeMultipliers(uint256[] _tokenIds, uint256[] _multipliers) external
Vendor -> called via Redeemer multiplier should assume 1x = 1,000,000 by default unless changed
Sets custom redemption fee multipliers for specific tokenIds for a vendor
Name | Type | Description |
---|---|---|
_tokenIds | uint256[] | Array of tokenIds |
_multipliers | uint256[] | Array of multipliers |
getCustomRedemptionFeeMultiplierForToken
function getCustomRedemptionFeeMultiplierForToken(uint256 tokenId) external view returns (uint256)
Vendor -> called via Redeemer
Returns the custom redemption fee multiplier for a token
Name | Type | Description |
---|---|---|
tokenId | uint256 | tokenId to check |
Name | Type | Description |
---|---|---|
[0] | uint256 | multiplier multiplier for the token |
getPaymentInformation
function getPaymentInformation(uint256[] tokenIds, uint256[] amounts, enum IPhygitalRedeemerFeeProcessor.RedeemedTokenType redeemedTokenType) external view returns (struct IPhygitalRedeemerFeeProcessor.PaymentInformation)
Utility -> called via Redeemer
Returns the payment information for a redemption request * returns all possible payment options
Name | Type | Description |
---|---|---|
tokenIds | uint256[] | array of tokenIds to be redeemed |
amounts | uint256[] | array of amounts to be redeemed |
redeemedTokenType | enum IPhygitalRedeemerFeeProcessor.RedeemedTokenType |
Name | Type | Description |
---|---|---|
[0] | struct IPhygitalRedeemerFeeProcessor.PaymentInformation | paymentInformation payment information |
handleRequestOpen
function handleRequestOpen(enum IPhygitalRedeemerFeeProcessor.RedeemedTokenType redeemedTokenType, bytes32 requestId, uint256[] tokenIds, uint256[] amounts, address paymentToken, address userAddress, uint256 msgValue) external
Utility
Handles the payment logic when a request is opened
Name | Type | Description |
---|---|---|
redeemedTokenType | enum IPhygitalRedeemerFeeProcessor.RedeemedTokenType | type of redeemed token |
requestId | bytes32 | requestId of the redemption request |
tokenIds | uint256[] | array of tokenIds to be redeemed |
amounts | uint256[] | array of amounts to be redeemed |
paymentToken | address | address of the payment token * address(0) for native payments |
userAddress | address | address of the user * used to handle ERC20 payment logic |
msgValue | uint256 | value of the native payment |
redemptionFeeDivisor
function redemptionFeeDivisor(address vendor) external view returns (uint256)
Utility
Returns the redemption fee divisor
IPhygitalRedeemerRegistry
CannotBeZeroAddress
error CannotBeZeroAddress()
Thrown when the zero address is passed.
TokenType
enum TokenType {
ERC721,
ERC1155
}
RedeemerInfo
struct RedeemerInfo {
address redeemer;
address token;
address provider;
enum IPhygitalRedeemerRegistry.TokenType tokenType;
address openRequestHooks;
}
isRedeemer
function isRedeemer(address redeemer) external view returns (bool)
Returns if an address is a redeemer
getRedeemers
function getRedeemers() external view returns (struct IPhygitalRedeemerRegistry.RedeemerInfo[] redeemers)
Returns the addresses of all Phygital Redeemer instances.
Name | Type | Description |
---|---|---|
redeemers | struct IPhygitalRedeemerRegistry.RedeemerInfo[] | Array of all Phygital Redeemer instances |
RedeemerRegister
event RedeemerRegister(address token, address provider, enum IPhygitalRedeemerRegistry.TokenType tokenType, address redeemer)
Emitted when a redeemer is registered.
Name | Type | Description |
---|---|---|
token | address | Address of the phygital token that can be redeemed. |
provider | address | Address of the redeemer's physical items' provider. |
tokenType | enum IPhygitalRedeemerRegistry.TokenType | Type of phygital token. |
redeemer | address | Address of the redeemer instance. |
getRedeemersForToken
function getRedeemersForToken(address token) external view returns (struct IPhygitalRedeemerRegistry.RedeemerInfo[] redeemers)
Returns the addresses of Phygital Redeemer instances associated to a given phygital token address.
Name | Type | Description |
---|---|---|
token | address | Address of the phygital token. |
Name | Type | Description |
---|---|---|
redeemers | struct IPhygitalRedeemerRegistry.RedeemerInfo[] | Array of Phygital Redeemer instances linked to the given phygital token. |
getRedeemersForProvider
function getRedeemersForProvider(address provider) external view returns (struct IPhygitalRedeemerRegistry.RedeemerInfo[] redeemers)
Returns the addresses of Phygital Redeemer instances associated to a given provider.
Name | Type | Description |
---|---|---|
provider | address | Address of the physical items' provider. |
Name | Type | Description |
---|---|---|
redeemers | struct IPhygitalRedeemerRegistry.RedeemerInfo[] | Array of Phygital Redeemer instances linked to the given provider. |
registerRedeemer
function registerRedeemer(address redeemer, address token, address provider, enum IPhygitalRedeemerRegistry.TokenType tokenType, address openRequestHooks) external
Can only be called by the regsitry owner.
Registers new Phygital Redeemer instance.
Name | Type | Description |
---|---|---|
redeemer | address | Address of the new Phygital Redeemer to register. |
token | address | Address of the phygital token that can |
provider | address | Address of the physical items' provider. |
tokenType | enum IPhygitalRedeemerRegistry.TokenType | Type of phygital token. |
openRequestHooks | address | Address to call on request opening. Can be set to address(0) to ignore the hook |
pauseRedeemer
function pauseRedeemer(address redeemer) external
Can only be called by the registry owner.
Pauses Phygital Redeemer instance.
Name | Type | Description |
---|---|---|
redeemer | address | Address of the Redeemer instance to pause. |
unpauseRedeemer
function unpauseRedeemer(address redeemer) external
Can only be called by the registry owner.
Unpauses Phygital Redeemer instance.
Name | Type | Description |
---|---|---|
redeemer | address | Address of the Redeemer instance to unpause. |
setProtocolFeeAddress
function setProtocolFeeAddress(address _protocolFeeAddress) external
Can only be called by the factory owner. It only updates the maximum fulfillment duration for Redeemer instances that are created thereafter.
Sets the address of the protocol fee contract.
Name | Type | Description |
---|---|---|
_protocolFeeAddress | address | Address of the protocol fee contract. |
setFeeProcessorAddress
function setFeeProcessorAddress(address _feeProcessorAddress) external
Can only be called by the factory owner. It only updates the maximum fulfillment duration for Redeemer instances that are created thereafter.
Sets the address of the fee processor contract.
Name | Type | Description |
---|---|---|
_feeProcessorAddress | address | Address of the fee processor contract. |
batchUpdateProtocolAddress
function batchUpdateProtocolAddress(address _protocolFeeAddress) external
Updates protocol address across all redeemers.
Name | Type | Description |
---|---|---|
_protocolFeeAddress | address | Address of the protocol fee contract. |
batchUpdateFeeProcessorAddress
function batchUpdateFeeProcessorAddress(address _feeProcessorAddress) external
Updates fee processor address across all redeemers.
Name | Type | Description |
---|---|---|
_feeProcessorAddress | address | Address of the fee processor contract. |
feeProcessorAddress
function feeProcessorAddress() external view returns (address)
Returns the address of the fee processor contract.
protocolFeeAddress
function protocolFeeAddress() external view returns (address)
Returns the address of the protocol fee contract.
IProtocolFee
CannotBeZero
error CannotBeZero()
Thrown when zero was incorrectly passed.
TiersNotConsecutive
error TiersNotConsecutive()
Thrown when min tier limit is not greater than previous tiers min limit.
TokenNotAccepted
error TokenNotAccepted()
Thrown when token is not accepted for upfront payment.
CallerNotFeeProcessor
error CallerNotFeeProcessor()
Thrown when the caller is not the fee processor.
CannotBeZeroAddress
error CannotBeZeroAddress()
Thrown when the zero address is passed.
FeeTier
struct FeeTier {
uint256 tierStartBorder;
uint256 feeMultiplier;
}
generalERC20ProtocolFees
function generalERC20ProtocolFees(address paymentToken) external view returns (uint256)
Vendor/Owner
Getter for the base protocol fee payed in an ERC20 token.
Name | Type | Description |
---|---|---|
paymentToken | address | chosen ERC20 payment token |
Name | Type | Description |
---|---|---|
[0] | uint256 | fee protocol fee in payment token |
generalNativeProtocolFee
function generalNativeProtocolFee() external view returns (uint256)
Vendor/Owner
Getter for the base protocol fee payed in native token.
Name | Type | Description |
---|---|---|
[0] | uint256 | fee protocol fee in native token |
getTokensAcceptedByProtocol
function getTokensAcceptedByProtocol() external view returns (address[])
Vendor/Owner
Getter for ERC20 tokens accepted by the protocol.
Name | Type | Description |
---|---|---|
[0] | address[] | tokensAcceptedByProtocol array of ERC20 tokens accepted by the protocol |
protocolAcceptsNative
function protocolAcceptsNative() external view returns (bool)
Vendor/Owner
Utility function, returns whether the protocol accepts native token for fee payment.
Name | Type | Description |
---|---|---|
[0] | bool | bool true if native token can be used for fee payments |
protocolFeeReceiver
function protocolFeeReceiver() external view returns (address)
Owner/Utility
returns the address to which protocol fees will be sent.
Name | Type | Description |
---|---|---|
[0] | address | protocolFeeReceiver address to which protocol fees are sent |
setRegistryAddress
function setRegistryAddress(address registryContract_) external
Owner Can only be called by the owner.
Sets the address of the registry contract.
Name | Type | Description |
---|---|---|
registryContract_ | address | Address of the registry contract. |
setProtocolFeeReceiver
function setProtocolFeeReceiver(address _protocolFeeReceiver) external
Owner
Setter for address to which protocol fees will be sent.
Name | Type | Description |
---|---|---|
_protocolFeeReceiver | address | address to which protocol fees will be sent |
setProtocolFeeTiers
function setProtocolFeeTiers(struct IProtocolFee.FeeTier[] _protocolFeeTiers) external
Owner
Setter for protocol fee tiers * determines if an extra fee should be added to the redemption fee.
Name | Type | Description |
---|---|---|
_protocolFeeTiers | struct IProtocolFee.FeeTier[] | protocol fee tiers * should be in ascending order |
setProtocolFeeNative
function setProtocolFeeNative(uint256 _protocolFee) external
Owner
Setter for base protocol fee in native token.
Name | Type | Description |
---|---|---|
_protocolFee | uint256 | protocol fee in native token |
setProtocolFee
function setProtocolFee(address _token, uint256 _fee) external
Owner
Setter for base protocol fee in ERC20 token.
Name | Type | Description |
---|---|---|
_token | address | address of the ERC20 token |
_fee | uint256 | protocol fee in ERC20 token |
feeDivisor
function feeDivisor() external view returns (uint256)
Owner/Utility
Getter for protocol fee divisor used during tiered fee calculation.
Name | Type | Description |
---|---|---|
[0] | uint256 | feeDivisor divisor for fee precision |
tierDivisor
function tierDivisor() external view returns (uint256)
Owner/Utility
Getter for protocol fee tier divisor used to determine tier limits.
Name | Type | Description |
---|---|---|
[0] | uint256 | tierDivisor divisor for tier precision |
upfrontPaymentPrecision
function upfrontPaymentPrecision() external view returns (uint256)
Owner/Utility
Getter for protocol upfront payment divisor used to calculate upfront discounts.
Name | Type | Description |
---|---|---|
[0] | uint256 | upfrontPaymentPrecision divisor for tier precision |
protocolFeePaid
function protocolFeePaid(address vendorAddress) external view returns (uint256)
Vendor/Utility
Getter for the remaining protocol fee paid upfront by a vendor.
Name | Type | Description |
---|---|---|
vendorAddress | address | address of the vendor |
Name | Type | Description |
---|---|---|
[0] | uint256 | protocolFeePaid amount of protocol fee paid upfront |
payProtocolFeeUpfrontNative
function payProtocolFeeUpfrontNative(uint256 amount) external
Utility - called via Redeemer
Allows a vendor to pay for a protocol fee upfront in native token.
Name | Type | Description |
---|---|---|
amount | uint256 | amount to be paid upfront |
payProtocolFeeUpfront
function payProtocolFeeUpfront(address paymentToken, uint256 amount) external
Utility - called via Redeemer
Allows a vendor to pay for a protocol fee upfront in ERC20 token.
Name | Type | Description |
---|---|---|
paymentToken | address | address of the payment token |
amount | uint256 | amount to be paid upfront |
calculateProtocolFee
function calculateProtocolFee(address paymentToken, uint256 redemptionFee) external view returns (uint256)
Utility
Returns the total protocol fee payed in an ERC20/Native token * based on the protocol fee tiers and the due redemption fee.
Name | Type | Description |
---|---|---|
paymentToken | address | payment token, either ERC20 or address(0) for native |
redemptionFee | uint256 | redemption fee which will be paid |
Name | Type | Description |
---|---|---|
[0] | uint256 | fee protocol fee in payment token |
calculateUpfrontDiscount
function calculateUpfrontDiscount(address vendorOrigin, address paymentToken, uint256 protocolFee) external view returns (uint256)
Utility
Calculates how much upfront discount a user should receive, * based on the outstanding protocol fee paid by the vendor.
Name | Type | Description |
---|---|---|
vendorOrigin | address | address of the vendor |
paymentToken | address | payment token, either address(0) for native or ERC20 |
protocolFee | uint256 | protocol fee to be paid |
Name | Type | Description |
---|---|---|
[0] | uint256 | upfrontDiscount amount of upfront discount |
handleUpfrontDiscount
function handleUpfrontDiscount(address vendorOrigin, address paymentToken, uint256 calculatedDiscount) external
Utility
Allows the protocol to handle upfront discount * reduces the outstanding protocol fee paid by the vendor.
Name | Type | Description |
---|---|---|
vendorOrigin | address | address of the vendor |
paymentToken | address | payment token, either address(0) for native or ERC20 |
calculatedDiscount | uint256 | calculated upfront discount |
protocolAcceptsToken
function protocolAcceptsToken(address paymentToken) external view returns (bool)
Utility
Utility function, returns whether the protocol accepts a given ERC20 token. for fee payment
Name | Type | Description |
---|---|---|
paymentToken | address | chosen ERC20 payment token |
Name | Type | Description |
---|---|---|
[0] | bool | bool true if token can be used for fee payments |
isProtocolFeePaymentRequired
function isProtocolFeePaymentRequired() external view returns (bool)
Utility
Utility function, returns whether the protocol requires a fee payment.
Name | Type | Description |
---|---|---|
[0] | bool | bool true if protocol requires a fee payment |
IRequestOpenHooks1155
beforeRequestOpen1155
function beforeRequestOpen1155(bytes32 publicKey, uint256[] tokenIds, uint256[] amounts, bytes shippingAddress) external
Called before a redemption request is opened.
Name | Type | Description |
---|---|---|
publicKey | bytes32 | Public key of the user opening the request. |
tokenIds | uint256[] | Token IDs being redeemed. |
amounts | uint256[] | Amounts of each token ID being redeemed. |
shippingAddress | bytes | User's encrypted shipping address. |
IRequestOpenHooks721
beforeRequestOpen721
function beforeRequestOpen721(bytes32 publicKey, uint256[] tokenIds, bytes shippingAddress) external
Called before a redemption request is opened.
Name | Type | Description |
---|---|---|
publicKey | bytes32 | Public key of the user opening the request. |
tokenIds | uint256[] | Token IDs being redeemed. |
shippingAddress | bytes | User's encrypted shipping address. |
TokenIdWhitelist
Allows for whitelisting a token's specific token IDs
Add
event Add(uint256 addedTokenId, bool status)
Emitted when a new token ID gets whitelisted.
Name | Type | Description |
---|---|---|
addedTokenId | uint256 | Newly whitelisted token ID. |
status | bool | True if the token ID was not already whitelisted and was successfully added to the whitelist. |
AddBatch
event AddBatch(uint256[] addedTokenIds, bool[] statuses)
Emitted when a batch of new token IDs are whitelisted.
Name | Type | Description |
---|---|---|
addedTokenIds | uint256[] | Newly whitelisted token IDs. |
statuses | bool[] | Array of booleans, with each element being true if the token IDs were not already whitelisted and were added to the whitelist. |
Remove
event Remove(uint256 removedTokenId, bool status)
Emitted when an existing token ID gets removed from the whitelist.
Name | Type | Description |
---|---|---|
removedTokenId | uint256 | Token ID removed from the whitelist. |
status | bool | True if the token ID was previously whitelisted and was now successfully removed from the whitelist. |
TokenIdNotWhitelisted
error TokenIdNotWhitelisted(uint256 requestedTokenId)
Thrown when the token ID is not whitelisted.
Name | Type | Description |
---|---|---|
requestedTokenId | uint256 | Token ID requested. |
token
address token
Address of the ERC-721 or ERC-1155 token whose IDs are being whitelisted.
whitelistedTokenIds
struct EnumerableSet.UintSet whitelistedTokenIds
Set of whitelisted token IDs.
constructor
constructor(address _token) public
list
function list() external view returns (uint256[])
Returns all of the whitelisted token IDs.
Name | Type | Description |
---|---|---|
[0] | uint256[] | List of whitelisted token IDs. |
count
function count() external view returns (uint256)
Returns the number of whitelisted token IDs.
Name | Type | Description |
---|---|---|
[0] | uint256 | The number of whitelisted token IDs. |
contains
function contains(uint256 tokenId) external view returns (bool)
Checks if a given token ID is whitelisted.
Name | Type | Description |
---|---|---|
tokenId | uint256 | Token ID to check. |
Name | Type | Description |
---|---|---|
[0] | bool | True if the token ID is whitelisted. |
add
function add(uint256 tokenId) external returns (bool)
Whitelists a give token ID.
Name | Type | Description |
---|---|---|
tokenId | uint256 | Token ID to be whilelisted. |
Name | Type | Description |
---|---|---|
[0] | bool | True if the token ID was not already whitelisted and was successfully added to the whitelist. |
addBatch
function addBatch(uint256[] tokenIds) external returns (bool[])
Whitelists a multiple given token IDs.
Name | Type | Description |
---|---|---|
tokenIds | uint256[] | Array of token IDs to be whilelisted. |
Name | Type | Description |
---|---|---|
[0] | bool[] | Array of booleans, with each element being true if the token IDs were not already whitelisted and were successfully added to the whitelist. |
remove
function remove(uint256 tokenId) external returns (bool)
Removes a give token ID from the whitelist.
Name | Type | Description |
---|---|---|
tokenId | uint256 | Token ID to be removed from the whitelist. |
Name | Type | Description |
---|---|---|
[0] | bool | True if the token ID was previously whitelisted and was now successfully removed from the whitelist. |
TokenIdWhitelist1155
The contract implements IRequestOpenHooks1155 and its address should be provided when deploying a new redeemer contract.
Allows for whitelisting specific phygital token IDs which can be redeemed using a PhygitalRedeemer1155 instance.
constructor
constructor(address token) public
beforeRequestOpen1155
function beforeRequestOpen1155(bytes32, uint256[] tokenIds, uint256[], bytes) external view
Called before a redemption request is opened.
Name | Type | Description |
---|---|---|
bytes32 | ||
tokenIds | uint256[] | Token IDs being redeemed. |
uint256[] | ||
bytes |
TokenIdWhitelist721
The contract implements IRequestOpenHooks721 and its address should be provided when deploying a new redeemer contract.
Allows for whitelisting specific phygital token IDs which can be redeemed using a PhygitalRedeemer721 instance.
constructor
constructor(address token) public
beforeRequestOpen721
function beforeRequestOpen721(bytes32, uint256[] tokenIds, bytes) external view
Called before a redemption request is opened.
Name | Type | Description |
---|---|---|
bytes32 | ||
tokenIds | uint256[] | Token IDs being redeemed. |
bytes |