Skip to main content
Helpful?

ERC721Permit_v4

Git Source | Generated with forge doc

Inherits: ERC721, IERC721Permit_v4, EIP712_v4, UnorderedNonce

Nonfungible tokens that support an approve via signature, i.e. permit

Functions

constructor

Computes the nameHash and versionHash

constructor(string memory name_, string memory symbol_) ERC721(name_, symbol_) EIP712_v4(name_);

checkSignatureDeadline

Checks if the block's timestamp is before a signature's deadline

modifier checkSignatureDeadline(uint256 deadline);

permit

Approve of a specific token ID for spending by spender via signature

payable so it can be multicalled with NATIVE related actions

function permit(address spender, uint256 tokenId, uint256 deadline, uint256 nonce, bytes calldata signature)
external
payable
checkSignatureDeadline(deadline);

Parameters

NameTypeDescription
spenderaddressThe account that is being approved
tokenIduint256The ID of the token that is being approved for spending
deadlineuint256The deadline timestamp by which the call must be mined for the approve to work
nonceuint256a unique value, for an owner, to prevent replay attacks; an unordered nonce where the top 248 bits correspond to a word and the bottom 8 bits calculate the bit position of the word
signaturebytesConcatenated data from a valid secp256k1 signature from the holder, i.e. abi.encodePacked(r, s, v)

permitForAll

Set an operator with full permission to an owner's tokens via signature

payable so it can be multicalled with NATIVE related actions

function permitForAll(
address owner,
address operator,
bool approved,
uint256 deadline,
uint256 nonce,
bytes calldata signature
) external payable checkSignatureDeadline(deadline);

Parameters

NameTypeDescription
owneraddressThe address that is setting the operator
operatoraddressThe address that will be set as an operator for the owner
approvedboolThe permission to set on the operator
deadlineuint256The deadline timestamp by which the call must be mined for the approve to work
nonceuint256a unique value, for an owner, to prevent replay attacks; an unordered nonce where the top 248 bits correspond to a word and the bottom 8 bits calculate the bit position of the word
signaturebytesConcatenated data from a valid secp256k1 signature from the holder, i.e. abi.encodePacked(r, s, v)

setApprovalForAll

Enable or disable approval for a third party ("operator") to manage all of msg.sender's assets

Emits the ApprovalForAll event. The contract MUST allow multiple operators per owner.

Override Solmate's ERC721 setApprovalForAll so setApprovalForAll() and permit() share the _approveForAll method

function setApprovalForAll(address operator, bool approved) public override;

Parameters

NameTypeDescription
operatoraddressAddress to add to the set of authorized operators
approvedboolTrue if the operator is approved, false to revoke approval

_approveForAll

function _approveForAll(address owner, address operator, bool approved) internal;

approve

Change or reaffirm the approved address for an NFT

override Solmate's ERC721 approve so approve() and permit() share the _approve method Passing a spender address of zero can be used to remove any outstanding approvals Throws error unless msg.sender is the current NFT owner, or an authorized operator of the current owner.

function approve(address spender, uint256 id) public override;

Parameters

NameTypeDescription
spenderaddressThe new approved NFT controller
iduint256The tokenId of the NFT to approve

_approve

function _approve(address owner, address spender, uint256 id) internal;

_isApprovedOrOwner

function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool);

tokenURI

function tokenURI(uint256) public pure override returns (string memory);
Helpful?