Smart Contracts¶
Shop Registry¶
The Shop Registry is an extension of EIP721.
Therefore each registered shop is an NFT and the contract comes with the associated functions, like mint
, ownerOf
, transferFrom
and approve
.
The shopId
is chosen by the caller. Minting already taken IDs will lead to a revert.
User Invitation¶
The user-facing way to add Clerks to a shop is through the use of an invitation (See Onboarding a Clerk). The contract offers these functions:
Shop Configuration¶
To add and remove Relays from your Shop the contract offers these functions:
Manual User Management¶
To manually add or remove a Clerk (a type of User), an Admin can call these functions:
Full Contract Listing¶
- contract ShopReg is AccessControl¶
-
function mint(uint256 shopId, address owner)¶
public
¶ - Notice:
mint registers a new shop and creates a NFT for it
- Parameters:
shopId – The shop nft. Needs to be unique or it will revert
owner – The owner of the shop
-
function updateRootHash(uint256 shopId, bytes32 hash, uint64 _nonce)¶
public
¶ - Notice:
updateRootHash updates the state root of the shop
- Parameters:
shopId – The shop nft
hash – The new state root hash
-
function getAllRelays(uint256 shopId)¶
public
view
returns (uint256[] memory)
¶ - Notice:
getAllRelays returns all relays for a shop
- Parameters:
shopId – The shop nft
- Return:
An array of relay nfts
-
function addRelay(uint256 shopId, uint256 relayId)¶
public
¶ - Notice:
addRelay adds a relay to the shop
- Parameters:
shopId – The shop nft
relayId – The relay nft
-
function replaceRelay(uint256 shopId, uint8 idx, uint256 relayId)¶
public
¶ - Notice:
replaceRelay replaces a relay in the shop
- Parameters:
shopId – The shop nft
idx – The index of the relay to replace
relayId – The new relay nft
-
function removeRelay(uint256 shopId, uint8 idx)¶
public
¶ - Notice:
removeRelay removes a relay from the shop
- Parameters:
shopId – The shop nft
idx – The index of the relay to remove
-
function publishInviteVerifier(uint256 shopId, address verifier)¶
public
¶ INVITES
- Notice:
adds a new one-time use registration invite to the shop
- Parameters:
shopId – The shop nft
verifier – The address of the invite verifier (public key)
-
function redeemInvite(uint256 shopId, uint8 v, bytes32 r, bytes32 s, address user)¶
public
¶ - Notice:
redeem one of the invites. (v,r,s) are the signature
- Parameters:
shopId – The shop nft
v – The recovery id
r – The r value of the signature
s – The s value of the signature
user – The address of the user to register. Will become a Clerk.
-
function mint(uint256 shopId, address owner)¶
- contract AccessControl is ERC721¶
Abstract contract to manage access control to a Shop.
Checks if a user has a single permission
Returns a user’s perimsion bitmap
Converts an array of permissions to a bitmap
Relay Registry¶
Just like the Shop Registry, the Relay Registry is an extension of EIP721.
Payments v2¶
Next iteration, using a single contract for all payments. Will support attestations and refunds.
- contract Payments is IPayments¶
- IPermit2 permit2¶
- LibBitmap.Bitmap paymentBitmap¶
-
function payToken(PaymentRequest calldata payment, bytes calldata permit2signature)¶
public
¶ - Inheritdoc:
IPaymentFunctions
-
function payTokenPreApproved(PaymentRequest calldata payment)¶
public
¶ - Inheritdoc:
IPaymentFunctions
-
function multiPay(PaymentRequest[] calldata payments, bytes[] calldata permit2Sigs)¶
public
payable
¶ - Inheritdoc:
IPaymentFunctions
- struct PaymentRequest¶
Holds the Payment details
- Members:
chainId (uint256) – The network the payment is supposed to be made on
ttl (uint256) – The deadline for the payment (block.timestamp)
order (bytes32) – The hash of the order details
currency (address) – The address of the ERC20 token to be transferred
amount (uint256) – The amount of tokens to be transferred
payeeAddress (address) – The address that will receive the payment
isPaymentEndpoint (bool) – Whether the payment should be forwarded with another contract call. See IPaymentEndpoint.
shopId (uint256) – The token id of the shop
shopSignature (bytes) – The signature of a merchant’s relay or signer
PaymentsByAddress¶
For wallets that don’t support direct function calls to pay, we support the creation of counterfactual instantiation via CREATE2
.