Skip to content

TypedData.getSignPayload

Gets the payload to use for signing typed data in EIP-712 format.

Imports

Named
import { TypedData } from 'ox'

Examples

import { Secp256k1, TypedData, Hash } from 'ox'
 
const payload = TypedData.getSignPayload({ 
  domain: {
    name: 'Ether Mail',
    version: '1',
    chainId: 1,
    verifyingContract: '0x0000000000000000000000000000000000000000',
  },
  types: {
    Person: [
      { name: 'name', type: 'string' },
      { name: 'wallet', type: 'address' },
    ],
    Mail: [
      { name: 'from', type: 'Person' },
      { name: 'to', type: 'Person' },
      { name: 'contents', type: 'string' },
    ],
  },
  primaryType: 'Mail',
  message: {
    from: {
      name: 'Cow',
      wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
    },
    to: {
      name: 'Bob',
      wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
    },
    contents: 'Hello, Bob!',
  },
})
 
const signature = Secp256k1.sign({ payload, privateKey: '0x...' })

Definition

function getSignPayload<typedData, primaryType>(
  value: encode.Value<typedData, primaryType>,
): Hex.Hex

Source: src/core/TypedData.ts

Parameters

value

  • Type: encode.Value<typedData, primaryType>

The typed data to get the sign payload for.

Return Type

The payload to use for signing.

Hex.Hex