ERC1238 tokens can only be minted to an EOA by providing a message signed by the recipient to

approve the minting, or batch minting, of tokens.

The ERC1238Approval contract isolates the logic around generating and verifying these signed messages and provides the methods for doing so through inheritance.

The implementation is based on EIP-712, a standard for typed structured data hashing and signing.

Implementation

Following EIP-712, the token recipient signs what is called here a “mint approval message” which could either be for a batch or a single token id and contain the following details about the minting transaction:

Single minting

struct MintApproval {
    address recipient;
    uint256 id;
    uint256 amount;
    uint256 approvalExpiry;
}

Batch minting

struct MintBatchApproval {
    address recipient;
    uint256[] ids;
    uint256[] amounts;
    uint256 approvalExpiry;
}

This results in an approval message hash, either a MintApprovalMessageHash or a a MintBatchApprovalMessageHash.

Expiry

As seen above, the approvals contain an approvalExpiry value, which is also signed by token recipients. This is to make sure that the consent obtained from them is bound in time. As an example, someone might agree to receive a token but then change their mind 4 months later. Without an expiry attached to the approval, an issuer would be able to keep the user’s signature, submit it and mint tokens a year after signing for example. The value set as approvalExpiry is left to application developers to determine but it is recommended to keep it not too distant in the future.