Last active
July 1, 2022 14:57
-
-
Save Hero-Development/6f90c83f2d3b37243a099e5de901860e to your computer and use it in GitHub Desktop.
Implementation contract receiving struct data and corresponding signature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; | |
import './Signed.sol'; | |
contract SignedData2B is IERC721, Signed{ | |
struct MintParams{ | |
uint id; | |
uint quantity; | |
uint32 expires; | |
} | |
uint public price = 0.01 ether; | |
mapping( uint => bool ) public used; | |
constructor() | |
//the address of our "signer" from step 1 | |
Signed( 0xd3bDe284cbdE2450EfdDA6f00D335467eB5fCc7b ) | |
{ | |
} | |
function presale( MintParams calldata params, bytes32 calldata signature ) external payable { | |
require( _isAuthorizedSigner( abi.encodePacked(params), signature ), "account not authorized" ); | |
require( !used[params.id] ); | |
require( params.expires > block.timestamp ); | |
require( params.quantity * price == msg.value ); | |
used[params.id] = true; | |
uint tokenId = totalSupply(); | |
for( uint i; i < params.quantity; ++i ){ | |
_mint( msg.sender, tokenId + i ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment