Created
September 14, 2022 03:49
-
-
Save ponyjackal/ea39aed0428c3c80ff23d0d6aa7433aa to your computer and use it in GitHub Desktop.
LazyMint using EIP712
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
// sign a message for LazyMintVoucher | |
const data = { | |
receiver: alice.address, | |
displayTypes: [ | |
ethers.utils.hexDataSlice(ethers.utils.formatBytes32String("paint"), 0, 16), | |
ethers.utils.hexDataSlice(ethers.utils.formatBytes32String("wheel"), 0, 16), | |
ethers.utils.hexDataSlice(ethers.utils.formatBytes32String("engine"), 0, 16), | |
], | |
traitTypes: [ | |
ethers.utils.hexDataSlice(ethers.utils.formatBytes32String("paint"), 0, 16), | |
ethers.utils.hexDataSlice(ethers.utils.formatBytes32String("wheel"), 0, 16), | |
ethers.utils.hexDataSlice(ethers.utils.formatBytes32String("engine"), 0, 16), | |
], | |
values: [ | |
ethers.utils.hexDataSlice(ethers.utils.formatBytes32String("blue"), 0, 16), | |
ethers.utils.hexDataSlice(ethers.utils.formatBytes32String("Alloy"), 0, 16), | |
ethers.utils.hexDataSlice(ethers.utils.formatBytes32String("v8"), 0, 16), | |
], | |
}; | |
const typedDomain = { | |
name: SIGNING_DOMAIN, | |
version: SIGNATURE_VERSION, | |
chainId: network.config.chainId, | |
verifyingContract: lazyMint.address, | |
}; | |
const signature = await admin._signTypedData(typedDomain, SIGNATURE_TYPES, data); | |
const voucher = { | |
...data, | |
signature, | |
}; | |
// mint a token to alice | |
await lazyMint.lazyMint(voucher); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment