Sign Typed

Sign Typed Data

sign-typed.tsx
import {
  signTypeData,
} from "@ramper-v2/multi";
 
const TYPE_DATA_TEST = JSON.stringify([
  {
    type: "string",
    name: "Message",
    value: "Hi, Alice!",
  },
  {
    type: "uint32",
    name: "A number",
    value: "1337",
  },
])
 
const handleSignTypeData = async () => {
  const result = await signTypeData({
    message: TYPE_DATA_TEST,
    type: 'eth_signTypedData',
    chain,
  });
};
 

Sign Typed Data V3

sign-typed-v3.tsx
  import {
    signTypeData,
  } from "@ramper-v2/multi";
 
  const TYPE_DATA_TEST =  JSON.stringify({
  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: 88,
    verifyingContract: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
  },
  message: {
    from: {
      name: "Cow",
      wallet: "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826",
    },
    to: { name: "Bob", wallet: "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB" },
    contents: "Hello, Bob!",
  },
})
 
const handleSignTypeDataV3 = async () => {
  const result = await signTypeData({
    message: TYPE_DATA_TEST,
    type: 'eth_signTypedData_v3',
    chain,
  });
};
 

Sign Typed Data V4

import {
  signTypeData,
} from "@ramper-v2/multi";
 
const TYPE_DATA_TEST = JSON.stringify({
  domain: {
    chainId: "88",
    name: "Ether Mail",
    verifyingContract: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
    version: "1",
  },
  message: {
    contents: "Hello, Bob!",
    from: {
      name: "Cow",
      wallets: [
        "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826",
        "0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF",
      ],
    },
    to: [
      {
        name: "Bob",
        wallets: [
          "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB",
          "0xB0BdaBea57B0BDABeA57b0bdABEA57b0BDabEa57",
          "0xB0B0b0b0b0b0B000000000000000000000000000",
        ],
      },
    ],
    attachment: "0x",
  },
  primaryType: "Mail",
  types: {
    EIP712Domain: [
      { name: "name", type: "string" },
      { name: "version", type: "string" },
      { name: "chainId", type: "uint256" },
      { name: "verifyingContract", type: "address" },
    ],
    Group: [
      { name: "name", type: "string" },
      { name: "members", type: "Person[]" },
    ],
    Mail: [
      { name: "from", type: "Person" },
      { name: "to", type: "Person[]" },
      { name: "contents", type: "string" },
      { name: "attachment", type: "bytes" },
    ],
    Person: [
      { name: "name", type: "string" },
      { name: "wallets", type: "address[]" },
    ],
  },
})
 
const handleSignTypeV4 = async () => {
  const result = await signTypeData({
    message: TYPE_DATA_TEST,
    type: 'eth_signTypedData_v4',
    chain,
  });
};
 

Last updated