Last active
March 24, 2022 18:09
-
-
Save Craigson/4db480600b8b723e10f46da47d7a537e to your computer and use it in GitHub Desktop.
EXR Biconomy implementation
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
pragma solidity 0.8.7; | |
import "./extensions/CouponSystem.sol"; | |
import "./EIP712MetaTransaction.sol"; | |
contract MyContract is CouponSystem { | |
bool public isGasless; | |
IEXRGameAsset public pilotContract; | |
IEXRMintPass public mintPassContract; | |
constructor(address pilot, address mintpass) { | |
isGasless = true; | |
pilotContract = IEXRGameAsset(pilot); | |
mintPassContract = IEXRMintPass(mintpass); | |
} | |
function redeemPilot(bytes32 seed, Coupon calldata coupon) external nonReentrant { | |
if (state.redeemPilot == 0) revert SalesPilotRedemptionNotActive(); | |
if (mintPassContract.balanceOf(getSender(), pilotPassTokenId) == 0) | |
revert SalesNoMintPass(); | |
bytes32 digest = keccak256(abi.encode(CouponType.RandomSeed, seed)); | |
if (!_verifyCoupon(digest, coupon)) revert SalesInvalidCoupon(); | |
mintPassContract.burnToRedeemPilot(getSender()); | |
emit MintPassBurned(getSender()); | |
pilotContract.mint(getSender(), 1, dedicatedFragment, seed); | |
} | |
function toggleGassless() external onlyOwner { | |
isGasless = !isGasless; | |
} | |
function getSender() internal view returns (uint256) { | |
if (isGasless) return msgSender(); | |
else return msg.sender; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment