Skip to content

Instantly share code, notes, and snippets.

@Hero-Development
Last active July 1, 2022 14:57
Show Gist options
  • Save Hero-Development/6f90c83f2d3b37243a099e5de901860e to your computer and use it in GitHub Desktop.
Save Hero-Development/6f90c83f2d3b37243a099e5de901860e to your computer and use it in GitHub Desktop.
Implementation contract receiving struct data and corresponding signature
// 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