Skip to content

Instantly share code, notes, and snippets.

@Craigson
Last active March 24, 2022 18:09
Show Gist options
  • Save Craigson/4db480600b8b723e10f46da47d7a537e to your computer and use it in GitHub Desktop.
Save Craigson/4db480600b8b723e10f46da47d7a537e to your computer and use it in GitHub Desktop.
EXR Biconomy implementation
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