Design Data Types

Define the types of the data you will be signing

Now we have decided what data we need to sign, let's decide the type of each field in the data.

It helps to make the EIP-712 standard generic and to be able to work with any data structure and types of data and to be agnostic to higher-level languages.

These are closely related to Solidity types.

Create data type for JSON Structure

const metaTransactionType = [
{ name: "nonce", type: "uint256" },
{ name: "from", type: "address" }
];

Create data type for Domain Separator

const domainType = [
{ name: "name", type: "string" },
{ name: "version", type: "string" },
{ name: "chainId", type: "uint256" },
{ name: "verifyingContract", type: "address" }
];

Complete Code Snippet

const domainType = [
{ name: "name", type: "string" },
{ name: "version", type: "string" },
{ name: "chainId", type: "uint256" },
{ name: "verifyingContract", type: "address" }
];
​
const metaTransactionType = [
{ name: "nonce", type: "uint256" },
{ name: "from", type: "address" }
];