Skip to main content
注意: 此页面尚未翻译成中文。以下内容为英文原版。
A TypedDataEncode prepares and encodes EIP-712 payloads for signed typed data. This is useful for those that wish to compute various components of a typed data hash, primary types, or sub-components, but generally the higher level Signer.signTypedData is more useful.

Constructors

new TypedDataEncoder()

Create a new TypedDataEncoder for types. This performs all necessary checking that types are valid and do not violate the EIP-712 structural constraints as well as computes the primaryType.

Parameters

Returns

TypedDataEncoder

Source

hash/typed-data.ts:259

Properties

Accessors

types

The types.

Returns

Record<string, TypedDataField[]>

Source

hash/typed-data.ts:244

Methods

encode()

Return the fulled encoded value for the types.

Parameters

Returns

string The encoded value.

Source

hash/typed-data.ts:465

encodeData()

Return the encoded value for the type.

Parameters

Returns

string The encoded value.

Source

hash/typed-data.ts:444

encodeType()

Return the full type for name.

Parameters

Returns

string The full type.

Source

hash/typed-data.ts:431

getEncoder()

Returnthe encoder for the specific type.

Parameters

Returns

Function The encoder for the type.
Parameters
Returns
string

Source

hash/typed-data.ts:365

hash()

Return the hash of the fully encoded value for the types.

Parameters

Returns

string The hash of the value.

Source

hash/typed-data.ts:475

hashStruct()

Returns the hash of value for the type of name.

Parameters

Returns

string The hash of the value.

Source

hash/typed-data.ts:455

visit()

Call calback for each value in value, passing the type and component within value. This is useful for replacing addresses or other transformation that may be desired on each component, based on its type.

Parameters

Returns

any The result of the callback.

Source

hash/typed-data.ts:528

encode()

Return the fully encoded EIP-712 value for types with domain.

Parameters

Returns

string The encoded value.

Source

hash/typed-data.ts:599

from()

Create a new TypedDataEncoder for types.

Parameters

Returns

TypedDataEncoder The encoder for the types.

Throws

If the types are invalid.

Source

hash/typed-data.ts:539

getPayload()

Returns the JSON-encoded payload expected by nodes which implement the JSON-RPC EIP-712 method.

Parameters

Returns

any The JSON-encoded payload.

Source

hash/typed-data.ts:633

getPrimaryType()

Return the primary type for types.

Parameters

Returns

string The primary type.

Throws

If the types are invalid.

Source

hash/typed-data.ts:550

hash()

Return the hash of the fully encoded EIP-712 value for types with domain.

Parameters

Returns

string The hash of the value.

Source

hash/typed-data.ts:616

hashDomain()

Return the domain hash for domain.

Parameters

Returns

string The hash of the domain.

Throws

If the domain is invalid.

Source

hash/typed-data.ts:573

hashStruct()

Return the hashed struct for value using types and name.

Parameters

Returns

string The hash of the value.

Source

hash/typed-data.ts:562