Permits
On this page, we explore the ways Immutable's preset contracts implement the permit feature. You will learn what permits are and when they can be used in game design.
What is a Permit?
Permits in ImmutableERC721
& ImmutableERC721MintById
are an implementation of EIP-4494.
To summarise EIP-4494
, Permit is an approval flow wherein the owner
signs a transaction that can grant approval for a spender
for an NFT.
Permits are messages locally signed using EIP-712 Signatures. They have the following syntax:
Permit(address spender, uint256 tokenId, uint256 nonce, uint256 deadline)
Where:
spender
is the address to grant approval totokenId
is the NFT Token ID to grant approval fornonce
is the nonce for that NFT, must be equal tononces(tokenId)
(also implemented inEIP-4494
)deadline
is a timestamp expiry for the permit
The nonce
is a crucial security feature that prevents the replay of a signature. Specifically, it ensures that a signature cannot be used multiple times on the same contract. It's important to note that the nonce
is incremented when an ERC721 token is transferred, not when the permit function is called. This distinction helps maintain the integrity of the contract's security and ensures that each action is unique and can only be executed once.
Why use Permit?
Gasless Approval
Permit allows gasless approval by the owner
locally signing a permit & submitting it to a spender off-chain. The spender can then submit the transaction themselves.
This is incredibly useful in combination with our multi-caller contract. You can get a "permit" from a user, then submit that with a burn in the same multi-call. It does not require the user to grant approveForAll
to the multi-caller contract.
Secure
Permit natively ensures that approval is invalidated once a token is transferred. It also introduces the concept of a deadline, approval is effectively revoked if the current time is after the deadline.
Why not use Approvals?
Approvals cost gas to provide permissions for future events which may not occur (e.g. Order listings may not get executed). Utilizing permits still costs gas, however this fee is only applied when the anticipated event occurs, eg. the approved spender will only submit the permit if they are submitting the transaction as well.
When to use Permits?
Trading: Permits serve as a valuable tool in marketplaces, relieving sellers from the need to pre-approve their NFTs for listing. The associated gas costs for permit execution are borne by the buyer, albeit only upon the actual execution of the transaction. Multi-call Contract: For tasks utilizing Immutable's preset Multi-call contract, permits offer versatility across various functions. Detailed information on these features will be provided here once they are fully developed and ready for use.