@soliditylabs/erc721-permit
v1.0.0
Published
Repository for implementing the ERC721 permit (EIP-4494).
Downloads
6
Maintainers
Readme
ERC721-permit
Package for implementing the ERC721 permit (EIP-4494). Unaudited, use at own risk.
Installation
- 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 { ERC721, ERC721Permit } from "@soliditylabs/erc20-permit/contracts/ERC20Permit.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);
}
}
Running tests
- 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