@sigpub/signatures-verify
v1.0.2
Published
Solidity smart contract library for verifying signature
Downloads
36
Maintainers
Readme
Installation
Use the following command to install @signatures-pub/signatures-verify
:
npm install @sigpub/signatures-verify
Usage
Once installed, you can use the contracts in the library by importing them:
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@sigpub/signatures-verify/Signature.sol";
contract MyNFT is ERC721 {
address private signerAddress;
mapping(address => uint256) public claimed;
constructor(address _signerAddress) ERC721("MyNFT", "MNFT") {
signerAddress = _signerAddress;
}
function whitelistMint(
uint256 quantity,
uint256 maxQuantity,
bytes memory signature
) external
{
require(Signature.verify(maxQuantity, msg.sender, signature) == signerAddress, "Address is not whitelisted");
require(claimed[msg.sender] + quantity <= maxQuantity, "Exceed current max minted");
claimed[msg.sender] += quantity;
_safeMint(msg.sender, quantity);
}
}