Package for implementing the ERC721 permit (EIP-4494). Unaudited, use at own risk.
- Install the package via NPM:
$ npm install @soliditylabs/erc721-permit --save-dev
Or Yarn:
$ yarn add @soliditylabs/erc721-permit --dev
- Import it into your ERC-721 contract:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { ERC721Permit } from "@soliditylabs/erc721-permit/contracts/ERC721Permit.sol";
contract NFTMock is ERC721Permit("Mock721", "MOCK") {
uint256 private _lastTokenId;
function mint() public {
_mint(msg.sender, ++_lastTokenId);
}
function safeTransferFromWithPermit(
address from,
address to,
uint256 tokenId,
bytes memory _data,
uint256 deadline,
bytes memory signature
) external {
_permit(msg.sender, tokenId, deadline, signature);
safeTransferFrom(from, to, tokenId, _data);
}
}
- Clone the repository
$ git clone https://github.com/soliditylabs/ERC721-Permit
- Install the dependencies
$ cd ERC721-Permit
$ npm install
- Run Hardhat Node
$ npx hardhat node
- Run tests
$ npm test