Skip to content

TypedData.serialize

Serializes EIP-712 Typed Data schema into string.

Imports

Named
import { TypedData } from 'ox'

Examples

import { TypedData } from 'ox'
 
TypedData.serialize({
  domain: {
    name: 'Ether!',
    version: '1',
    chainId: 1,
    verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
  },
  primaryType: 'Foo',
  types: {
    Foo: [
      { name: 'address', type: 'address' },
      { name: 'name', type: 'string' },
      { name: 'foo', type: 'string' },
    ],
  },
  message: {
    address: '0xb9CAB4F0E46F7F6b1024b5A7463734fa68E633f9',
    name: 'jxom',
    foo: '0xb9CAB4F0E46F7F6b1024b5A7463734fa68E633f9',
  },
})
"{"domain":{},"message":{"address":"0xb9cab4f0e46f7f6b1024b5a7463734fa68e633f9","name":"jxom","foo":"0xb9CAB4F0E46F7F6b1024b5A7463734fa68E633f9"},"primaryType":"Foo","types":{"Foo":[{"name":"address","type":"address"},{"name":"name","type":"string"},{"name":"foo","type":"string"}]}}"

Definition

function serialize<typedData, primaryType>(
  value: serialize.Value<typedData, primaryType>,
): string

Source: src/TypedData.ts

Parameters

value

  • Type: serialize.Value<typedData, primaryType>

The Typed Data schema to serialize.

Return Type

The serialized Typed Data schema. w

string