Skip to content

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.

requests

struct IPhygitalRedeemer1155.Request1155[] requests

Array of all the existing ERC-1155 redemption requests.

getRequests

function getRequests() public view returns (struct IPhygitalRedeemer1155.Request1155[])

Returns array of all the existing ERC-1155 redemption requests.

Name Type Description
[0] struct IPhygitalRedeemer1155.Request1155[]

getRequestsCount

function getRequestsCount() public view returns (uint256)

Returns the total number of requests that have been opened.

Name Type Description
[0] uint256

getRequest

function getRequest(uint256 requestId) external view returns (struct IPhygitalRedeemer1155.Request1155)

Returns request by its corresponding ID.

Name Type Description
[0] struct IPhygitalRedeemer1155.Request1155

getRequestBeneficiary

function getRequestBeneficiary(uint256 requestId) public view returns (address beneficiary)

Returns the beneficiary of the soulbound token.

Name Type Description
requestId uint256 Request ID whose beneficiary should be returned.
Name Type Description
beneficiary address Owner of the given request.

isRequestOwner

modifier isRequestOwner(uint256 requestId)

Modifier to make a function callable only when the msg.sender is the request owner.

_transferUserTokens

function _transferUserTokens(uint256 requestId) internal

Returns the deposited ERC-721 or ERC-1155 token(s) back to the user who opened the given request.

Name Type Description
requestId uint256 The ID of the request for which the underlying tokens should be returned to the user.

_burnTokens

function _burnTokens(uint256 requestId) internal

Burns the ERC-721 or ERC-1155 tokens that were deposited by the user once the given request was opened.

Name Type Description
requestId uint256 The ID of the request for which the underlying tokens should be burnt.

_transferEscrowToRedeemer

function _transferEscrowToRedeemer(uint256 requestId) internal

Utility function, transfers the escrowed payment to the redeemer.

openRequest

function openRequest(bytes32 publicKey, uint256[] tokenIds, uint256[] amounts, bytes shippingAddress, address paymentToken) external payable returns (uint256 requestId)

Opens a new request with ERC20 token used in redemption fee.

Name Type Description
publicKey bytes32 Public key of the redeemer.
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 uint256 Unique ID for the opened request.

_openRequest

function _openRequest(bytes32 publicKey, uint256[] tokenIds, uint256[] amounts, bytes shippingAddress) internal returns (uint256 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.

requests

struct IPhygitalRedeemer721.Request721[] requests

Array of all the existing ERC-721 redemption requests.

defaultBurnMechanism

enum IPhygitalRedeemer721.BurnMechanism defaultBurnMechanism

Returns the default burn mechanism for the collection

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

init

function init(address protocolFeeAddress_, address feeProcessorAddress_, address _token, address _provider, bytes32 _providerPublicKey, uint256 _maxFulfillmentDuration, address _openRequestHooks, string name_, string symbol_, string baseTokenURI_) 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

getRequests

function getRequests() public view returns (struct IPhygitalRedeemer721.Request721[])

Returns array of all the existing ERC-721 redemption requests.

Name Type Description
[0] struct IPhygitalRedeemer721.Request721[]

getRequestsCount

function getRequestsCount() public view returns (uint256)

Returns the total number of requests that have been opened.

Name Type Description
[0] uint256

getRequest

function getRequest(uint256 requestId) external view returns (struct IPhygitalRedeemer721.Request721)

Returns request by its corresponding ID.

Name Type Description
[0] struct IPhygitalRedeemer721.Request721

getRequestBeneficiary

function getRequestBeneficiary(uint256 requestId) public view returns (address beneficiary)

Returns the beneficiary of the soulbound token.

Name Type Description
requestId uint256 Request ID whose beneficiary should be returned.
Name Type Description
beneficiary address Owner of the given request.

isRequestOwner

modifier isRequestOwner(uint256 requestId)

Modifier to make a function callable only when the msg.sender is the request owner.

_transferUserTokens

function _transferUserTokens(uint256 requestId) internal

Returns the deposited ERC-721 or ERC-1155 token(s) back to the user who opened the given request.

Name Type Description
requestId uint256 The ID of the request for which the underlying tokens should be returned to the user.

_burnTokens

function _burnTokens(uint256 requestId) internal

Burns the ERC-721 or ERC-1155 tokens that were deposited by the user once the given request was opened.

Name Type Description
requestId uint256 The ID of the request for which the underlying tokens should be burnt.

_transferEscrowToRedeemer

function _transferEscrowToRedeemer(uint256 requestId) internal

Utility function, transfers the escrowed payment to the redeemer.

_openRequest

function _openRequest(bytes32 publicKey, uint256[] tokenIds, bytes shippingAddress) internal returns (uint256 requestId)

openRequest

function openRequest(bytes32 publicKey, uint256[] tokenIds, bytes shippingAddress, address paymentToken) external payable returns (uint256 requestId)

Opens a new request with ERC20 token used in redemption fee

Name Type Description
publicKey bytes32 Public key of the redeemer.
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 uint256 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(uint256 => struct IPhygitalRedeemerCommon.RequestState) requestState

Maps request IDs to request states.

userRequestIds

mapping(address => uint256[]) userRequestIds

Maps user addresses to the IDs of the requests that they have created.

paused

bool paused

True if the contracts are paused, false otherwise.

_name

string _name

Proof-of-redemption token name.

_symbol

string _symbol

Proof-of-redemption token symbol.

_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() internal

getRequestsCount

function getRequestsCount() public view virtual returns (uint256 count)

Returns the total number of requests that have been opened.

Name Type Description
count uint256 Total number of requests opened.

getRequestBeneficiary

function getRequestBeneficiary(uint256 requestId) public view virtual returns (address beneficiary)

Returns the beneficiary of the soulbound token.

Name Type Description
requestId uint256 Request ID whose beneficiary should be returned.
Name Type Description
beneficiary address Owner of the given request.

getRequestState

function getRequestState(uint256 requestId) external view returns (struct IPhygitalRedeemerCommon.RequestState)

Returns the given request's state.

Name Type Description
requestId uint256 ID of the request whose state to return.
Name Type Description
[0] struct IPhygitalRedeemerCommon.RequestState

getUserRequestIds

function getUserRequestIds(address owner) external view returns (uint256[])

Returns the IDs of the requests created by a given user.

Name Type Description
owner address Owner whose requests to look for.
Name Type Description
[0] uint256[]

getRequestsState

function getRequestsState(uint256 startId, uint256 maxCount) external view returns (struct IPhygitalRedeemerCommon.RequestState[] states)

Returns the state of multiple given requests.

Name Type Description
startId uint256 ID of the request to start the search from.
maxCount uint256 Maximum number of requests, preceding the given start ID, whose state to return.
Name Type Description
states struct IPhygitalRedeemerCommon.RequestState[] States of the associated requests.

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.

isInitialized

modifier isInitialized()

Modifier to make a function callable only when the contract is initialized.

isRequestOwner

modifier isRequestOwner(uint256 requestId)

Modifier to make a function callable only when the msg.sender is the request owner.

Name Type Description
requestId uint256 The ID for the request whose owner to check for.

_transferUserTokens

function _transferUserTokens(uint256 requestId) internal virtual

Returns the deposited ERC-721 or ERC-1155 token(s) back to the user who opened the given request.

Name Type Description
requestId uint256 The ID of the request for which the underlying tokens should be returned to the user.

_burnTokens

function _burnTokens(uint256 requestId) 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
requestId uint256 The ID of the request for which the underlying tokens should be burnt.

init

function init(address protocolFeeAddress_, address feeProcessorAddress_, address _token, address _provider, bytes32 _providerPublicKey, uint256 _maxFulfillmentDuration, address _openRequestHooks, string name_, string symbol_, string baseTokenURI_) public virtual

Can only be called once, following the contract's creation.

Initializes the Phygital Redeemer.

Name Type Description
protocolFeeAddress_ address
feeProcessorAddress_ address
_token address
_provider address
_providerPublicKey bytes32
_maxFulfillmentDuration uint256
_openRequestHooks address
name_ string
symbol_ string
baseTokenURI_ string

closeRequest

function closeRequest(uint256 requestId) 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
requestId uint256 ID of the request being closed.

acceptRequest

function acceptRequest(uint256 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 uint256 ID of the request being approved.

rejectRequest

function rejectRequest(uint256 requestId, 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
requestId uint256 ID of the request being rejected.
rejectionReason bytes Reason for rejecting the request.

fulfillRequest

function fulfillRequest(uint256 requestId, 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
requestId uint256 ID of the request being fulfilled.
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(uint256 requestId) 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
requestId uint256 ID of the request being expired.

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.

name

function name() public view returns (string)

Returns the proof-of-redemption token collection name.

symbol

function symbol() public view returns (string)

Returns the proof-of-redemption token collection symbol.

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(uint256 requestId) internal virtual

Utility function, transfers the escrowed payment to the redeemer.

_transferEscrow

function _transferEscrow(uint256 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(uint256 requestId) external view returns (struct IPhygitalRedeemerFeeProcessor.Escrow)

Vendor

Returns the escrow data for a redemption request

Name Type Description
requestId uint256 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

PhygitalRedeemerFactory

Responsible for the creation and management of PhygitalRedeemer instances.

protocolFeeAddress

address protocolFeeAddress

Address of the protocol fee contract.

feeProcessorAddress

address feeProcessorAddress

Address of the protocol fee contract.

phygitalRedeemer721Target

address phygitalRedeemer721Target

Skeleton contract used to fetch the bytecode for PhygitalRedeemer721.

phygitalRedeemer1155Target

address phygitalRedeemer1155Target

Skeleton contract used to fetch the bytecode for PhygitalRedeemer1155.

redeemers

struct IPhygitalRedeemerFactory.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.

maxFulfillmentDuration

uint256 maxFulfillmentDuration

The current maximum allowed fulfillment duration, in seconds, set for all new Redeemer instances.

constructor

constructor(uint256 _maxFulfillmentDuration, address _phygitalRedeemer721Target, address _phygitalRedeemer1155Target, address _protocolFeeAddress, address _feeProcessorAddress) public

getRedeemers

function getRedeemers() external view returns (struct IPhygitalRedeemerFactory.RedeemerInfo[])

Returns the addresses of all Phygital Redeemer instances.

Name Type Description
[0] struct IPhygitalRedeemerFactory.RedeemerInfo[]

getRedeemersForToken

function getRedeemersForToken(address token) external view returns (struct IPhygitalRedeemerFactory.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 IPhygitalRedeemerFactory.RedeemerInfo[]

getRedeemersForProvider

function getRedeemersForProvider(address provider) external view returns (struct IPhygitalRedeemerFactory.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 IPhygitalRedeemerFactory.RedeemerInfo[]

createRedeemer

function createRedeemer(address token, address provider, bytes32 providerPublicKey, enum IPhygitalRedeemerFactory.TokenType tokenType, address openRequestHooks, string name, string symbol, string tokenURI) external returns (address redeemer)

Can only be called by the factory owner.

Creates new Phygital Redeemer instance.

Name Type Description
token address Address of the phygital token that can
provider address Address of the physical items' provider.
providerPublicKey bytes32 Public key of the physical items' provider.
tokenType enum IPhygitalRedeemerFactory.TokenType Type of phygital token.
openRequestHooks address Address to call on request opening. can be set to address(0) to ignore the hook
name string Proof-of-redemption token collection name.
symbol string Proof-of-redemption token collection symbol.
tokenURI string Proof-of-redemption token metadata URI.
Name Type Description
redeemer address Address of the new redeemer instance.

pauseRedeemer

function pauseRedeemer(address redeemer) external

Can only be called by the factory 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 factory owner.

Unpauses Phygital Redeemer instance.

Name Type Description
redeemer address Address of the Redeemer instance to unpause.

setMaxFulfillmentDuration

function setMaxFulfillmentDuration(uint256 _maxFulfillmentDuration) external

Can only be called by the factory owner. It only updates the maximum fulfillment duration for Redeemer instances that are created thereafter. Existing Redeemer instances keep their old maximum fulfillment duration values.

Sets the maximum fulfillment duration.

Name Type Description
_maxFulfillmentDuration uint256 New maximum fulfillment duration, denominated in seconds.

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.

PhygitalRedeemerFeeProcessor

Responsible for the management of redemption and protocol fees for a specific Redeemer instance.

protocolFeeAddress

address protocolFeeAddress

Address of the protocol fee contract.

factoryAddress

address factoryAddress

Address of the factory

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(uint256 => 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, uint256 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 uint256 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(uint256 requestId) public view returns (struct IPhygitalRedeemerFeeProcessor.Escrow)

Vendor/Utility -> called via Redeemer

Returns the escrow data for a redemption request

Name Type Description
requestId uint256 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

setFactoryAddress

function setFactoryAddress(address factoryAddress_) external

Owner Can only be called by the owner.

Sets the address of the factory contract.

Name Type Description
factoryAddress_ address

_handleFeesNative

function _handleFeesNative(uint256 requestId, uint256 _redemptionFee, uint256 protocolFee, address userAddress, uint256 msgValue) internal

handler of native fee payments

_handleFees

function _handleFees(uint256 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

ProtocolFee

Responsible for the management of protocol fees across all Redeemer instances.

factoryAddress

address factoryAddress

Address of the factory

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

setFactoryAddress

function setFactoryAddress(address factoryAddress_) external

Owner Can only be called by the owner.

Sets the address of the factory contract.

Name Type Description
factoryAddress_ 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 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(uint256 requestId) external view returns (struct IPhygitalRedeemerFeeProcessor.Escrow)

Vendor

Returns the escrow data for a redemption request

Name Type Description
requestId uint256 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 {
  address owner;
  bytes32 ownerPublicKey;
  uint256[] tokenIds;
  uint256[] amounts;
  bytes shippingAddress;
}

TokenAmountZero

error TokenAmountZero()

Thrown when the token amount is zero

getRequests

function getRequests() external view returns (struct IPhygitalRedeemer1155.Request1155[] requests)

Returns array of all the existing ERC-1155 redemption requests.

Name Type Description
requests struct IPhygitalRedeemer1155.Request1155[] Array of all redeption requests.

getRequest

function getRequest(uint256 requestId) external view returns (struct IPhygitalRedeemer1155.Request1155 request)

Returns request by its corresponding ID.

Name Type Description
request struct IPhygitalRedeemer1155.Request1155 Request associated to the given request ID.

openRequest

function openRequest(bytes32 publicKey, uint256[] tokenIds, uint256[] amounts, bytes shippingAddress, address paymentToken) external payable returns (uint256 requestId)

Opens a new request with ERC20 token used in redemption fee.

Name Type Description
publicKey bytes32 Public key of the redeemer.
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 uint256 Unique ID for the opened request.

IPhygitalRedeemer721

AlreadyRedeemed

error AlreadyRedeemed()

Thrown when a token is already redeemed

Request721

struct Request721 {
  address owner;
  bytes32 ownerPublicKey;
  uint256[] tokenIds;
  bytes shippingAddress;
}

BurnMechanism

enum BurnMechanism {
  Default,
  Burn,
  Mark,
  Reredeemable
}

getRequests

function getRequests() external view returns (struct IPhygitalRedeemer721.Request721[] requests)

Returns array of all the existing ERC-721 redemption requests.

Name Type Description
requests struct IPhygitalRedeemer721.Request721[] Array of all redeption requests.

getRequest

function getRequest(uint256 requestId) external view returns (struct IPhygitalRedeemer721.Request721 request)

Returns request by its corresponding ID.

Name Type Description
request struct IPhygitalRedeemer721.Request721 Request associated to the given request ID.

openRequest

function openRequest(bytes32 publicKey, uint256[] tokenIds, bytes shippingAddress, address paymentToken) external payable returns (uint256 requestId)

Opens a new request with ERC20 token used in redemption fee

Name Type Description
publicKey bytes32 Public key of the redeemer.
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 uint256 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;
  bytes providerMessage;
}

RequestStatusUpdate

event RequestStatusUpdate(uint256 requestId, enum IPhygitalRedeemerCommon.RequestStatus updatedStatus)

Emitted when a request status gets updated.

Name Type Description
requestId uint256 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 received)

Thrown when the request is in an unexpected status.

Name Type Description
expected enum IPhygitalRedeemerCommon.RequestStatus Expected request status.
received enum IPhygitalRedeemerCommon.RequestStatus Actual request status received.

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.

ContractAlreadyInitialized

error ContractAlreadyInitialized()

Thrown when an initialization attempt is made on an already-initialized Phygital Redeemer contract.

ContractNotInitialized

error ContractNotInitialized()

Thrown when a request is opened on an un-initialized Phygital Redeemer contract.

TokensAmountsMismatch

error TokensAmountsMismatch()

Thrown when the size of the token list does not match the size of the amounts.

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.

getRequestsCount

function getRequestsCount() external view returns (uint256 count)

Returns the total number of requests that have been opened.

Name Type Description
count uint256 Total number of requests opened.

getRequestState

function getRequestState(uint256 requestId) external view returns (struct IPhygitalRedeemerCommon.RequestState state)

Returns the given request's state.

Name Type Description
requestId uint256 ID of the request whose state to return.
Name Type Description
state struct IPhygitalRedeemerCommon.RequestState State associated to the given request.

getRequestsState

function getRequestsState(uint256 startId, uint256 maxCount) external view returns (struct IPhygitalRedeemerCommon.RequestState[] states)

Returns the state of multiple given requests.

Name Type Description
startId uint256 ID of the request to start the search from.
maxCount uint256 Maximum number of requests, preceding the given start ID, whose state to return.
Name Type Description
states struct IPhygitalRedeemerCommon.RequestState[] States of the associated requests.

getUserRequestIds

function getUserRequestIds(address owner) external view returns (uint256[] requestIds)

Returns the IDs of the requests created by a given user.

Name Type Description
owner address Owner whose requests to look for.
Name Type Description
requestIds uint256[] IDs of the requests associated with the owner.

getRequestBeneficiary

function getRequestBeneficiary(uint256 requestId) external view returns (address beneficiary)

Returns the beneficiary of the soulbound token.

Name Type Description
requestId uint256 Request ID whose beneficiary should be returned.
Name Type Description
beneficiary address Owner of the given request.

init

function init(address protocolFeeContract_, address feeProcessorAddress_, address token, address provider, bytes32 providerPublicKey, uint256 maxFulfillmentDuration, address openRequestHooks, string name, string symbol, string tokenURI) external

Can only be called once, following the contract's creation.

Initializes the Phygital Redeemer.

Name Type Description
protocolFeeContract_ address Address of the protocol fee contract.
feeProcessorAddress_ address
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.
tokenURI string Proof-of-redemption token metadata URI.

closeRequest

function closeRequest(uint256 requestId) 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
requestId uint256 ID of the request being closed.

acceptRequest

function acceptRequest(uint256 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 uint256 ID of the request being approved.

rejectRequest

function rejectRequest(uint256 requestId, 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
requestId uint256 ID of the request being rejected.
rejectionReason bytes Reason for rejecting the request.

fulfillRequest

function fulfillRequest(uint256 requestId, 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
requestId uint256 ID of the request being fulfilled.
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(uint256 requestId) 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
requestId uint256 ID of the request being expired.

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

IPhygitalRedeemerFactory

CannotBeAddressZero

error CannotBeAddressZero()

Emitted when the new protocol fee contract address is incorrect

TokenType

enum TokenType {
  ERC721,
  ERC1155
}

RedeemerInfo

struct RedeemerInfo {
  address redeemer;
  address token;
  address provider;
  enum IPhygitalRedeemerFactory.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 IPhygitalRedeemerFactory.RedeemerInfo[] redeemers)

Returns the addresses of all Phygital Redeemer instances.

Name Type Description
redeemers struct IPhygitalRedeemerFactory.RedeemerInfo[] Array of all Phygital Redeemer instances

RedeemerCreate

event RedeemerCreate(address token, address provider, enum IPhygitalRedeemerFactory.TokenType tokenType, address redeemer)

Emitted when a redeemer is created.

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 IPhygitalRedeemerFactory.TokenType Type of phygital token.
redeemer address Address of the redeemer instance.

getRedeemersForToken

function getRedeemersForToken(address token) external view returns (struct IPhygitalRedeemerFactory.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 IPhygitalRedeemerFactory.RedeemerInfo[] Array of Phygital Redeemer instances linked to the given phygital token.

getRedeemersForProvider

function getRedeemersForProvider(address provider) external view returns (struct IPhygitalRedeemerFactory.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 IPhygitalRedeemerFactory.RedeemerInfo[] Array of Phygital Redeemer instances linked to the given provider.

createRedeemer

function createRedeemer(address token, address provider, bytes32 providerPublicKey, enum IPhygitalRedeemerFactory.TokenType tokenType, address openRequestHooks, string name, string symbol, string tokenURI) external returns (address redeemer)

Can only be called by the factory owner.

Creates new Phygital Redeemer instance.

Name Type Description
token address Address of the phygital token that can
provider address Address of the physical items' provider.
providerPublicKey bytes32 Public key of the physical items' provider.
tokenType enum IPhygitalRedeemerFactory.TokenType Type of phygital token.
openRequestHooks address Address to call on request opening. can be set to address(0) to ignore the hook
name string Proof-of-redemption token collection name.
symbol string Proof-of-redemption token collection symbol.
tokenURI string Proof-of-redemption token metadata URI.
Name Type Description
redeemer address Address of the new redeemer instance.

pauseRedeemer

function pauseRedeemer(address redeemer) external

Can only be called by the factory 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 factory owner.

Unpauses Phygital Redeemer instance.

Name Type Description
redeemer address Address of the Redeemer instance to unpause.

setMaxFulfillmentDuration

function setMaxFulfillmentDuration(uint256 _maxFulfillmentDuration) external

Can only be called by the factory owner. It only updates the maximum fulfillment duration for Redeemer instances that are created thereafter. Existing Redeemer instances keep their old maximum fulfillment duration values.

Sets the maximum fulfillment duration.

Name Type Description
_maxFulfillmentDuration uint256 New maximum fulfillment duration, denominated in seconds.

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.

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 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.

setFactoryAddress

function setFactoryAddress(address factoryContract_) external

Owner Can only be called by the owner.

Sets the address of the factory contract.

Name Type Description
factoryContract_ address Address of the factory 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(uint256 requestId) external view returns (struct IPhygitalRedeemerFeeProcessor.Escrow)

Vendor/Utility -> called via Redeemer

Returns the escrow data for a redemption request

Name Type Description
requestId uint256 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, uint256 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 uint256 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

IProtocolFee

CannotBeZero

error CannotBeZero()

Emitted when value cannot be zero

TiersNotConsecutive

error TiersNotConsecutive()

Emitted when min tier limit is not greater than previous tiers min limit

TokenNotAccepted

error TokenNotAccepted()

Emitted when token is not accepted for upfront payment

CallerNotFeeProcessor

error CallerNotFeeProcessor()

Emitted when the caller is not the fee processor

CannotBeZeroAddress

error CannotBeZeroAddress()

Thrown when the zero address 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

setFactoryAddress

function setFactoryAddress(address factoryContract_) external

Owner Can only be called by the owner.

Sets the address of the factory contract.

Name Type Description
factoryContract_ address Address of the factory 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