In order to approve someone to mint a Badge, a signature using EIP-712 is necessary
import { utils } from "ethers"
const typedData = {
domain: {
name: 'BADGES',
version: '1.0.0',
chainId: 10, // optimism chainId
verifyingContract: '0x7F9279B24D1c36Fa3E517041fdb4E8788dc63D25',
},
types: {
Agreement: [
{ name: 'active', type: 'address' },
{ name: 'passive', type: 'address' },
{ name: 'tokenURI', type: 'string' },
],
},
value: {
active: claimant.address, // issuer of badge
passive: issuer.address, // receiver of badge
tokenURI: specUri, // uri of badge
},
}
// See: <https://docs.ethers.io/v5/api/signer/#Signer-signTypedData> for more detailed instructions.
const signature = await signer._signTypedData(typedData.domain, typedData.types, typedData.value)
const { compactSignature } = utils.splitSignature(signature)