eth_signTypedData_v4

Presents a data message for the user to sign in a structured and readable format and returns the signed response. Introduced by EIP-712. This method requires that the user has granted permission to interact with their account first, so make sure to call eth_requestAccounts first.

Params

1. Address (required)

The address of the requested signing account.

string

Match pattern:^0x[0-9a-fA-F]{40}$

2. TypedData (required)

type TypedDataParameters = {
    types: MessageTypes;
    primaryType: keyof MessageTypes;
    domain: {
        name?: string;
        version?: string;
        chainId?: number;
        verifyingContract?: string;
        salt?: ArrayBuffer;
    };
    message: Record<string, unknown>; // The message you're proposing the user to sign.
};

type MessageTypes = {
    EIP712Domain: MessageTypeProperty[];
    [additionalProperties: string]: MessageTypeProperty[];
};

type MessageTypeProperty = {
    name: string;
    type: string;
};

Result

string

Match pattern: ^0x[0-9a-f]*$

Example

Request

await window.NEOLineNeoX.request({
  "method": "eth_signTypedData_v4",
  "params": [
    "0xE45e9AdC2B51514849ea5B38dF37d1a65e6D52f5",
    {
      "types": {
        "EIP712Domain": [
          {
            "name": "name",
            "type": "string"
          },
          {
            "name": "version",
            "type": "string"
          },
          {
            "name": "chainId",
            "type": "uint256"
          },
          {
            "name": "verifyingContract",
            "type": "address"
          }
        ],
        "Person": [
          {
            "name": "name",
            "type": "string"
          },
          {
            "name": "wallet",
            "type": "address"
          }
        ],
        "Mail": [
          {
            "name": "from",
            "type": "Person"
          },
          {
            "name": "to",
            "type": "Person"
          },
          {
            "name": "contents",
            "type": "string"
          }
        ]
      },
      "primaryType": "Mail",
      "domain": {
        "name": "Ether Mail",
        "version": "1",
        "chainId": 1,
        "verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"
      },
      "message": {
        "from": {
          "name": "Cow",
          "wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"
        },
        "to": {
          "name": "Bob",
          "wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"
        },
        "contents": "Hello, Bob!"
      }
    }
  ]
});

Result

"0x429ccb1fa34f8bd8f367e60f035dc7dd530335644617da8dff3cbfb3ef10ed90731c305676e229c2e30f8c1b910095ca2bcde77215dabe995932d5da87b42ee81c"

最后更新于