> ## Documentation Index
> Fetch the complete documentation index at: https://voltaire.tevm.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# primitives/TypedData

> Auto-generated API documentation

[**@tevm/voltaire**](../index.mdx)

***

[@tevm/voltaire](../index.mdx) / primitives/TypedData

# primitives/TypedData

## Classes

### InvalidTypedDataError

Defined in: [src/primitives/TypedData/errors.js:4](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/TypedData/errors.js#L4)

Error thrown when TypedData is invalid

#### Extends

* `Error`

#### Constructors

##### Constructor

> **new InvalidTypedDataError**(`message`, `context?`): [`InvalidTypedDataError`](#invalidtypeddataerror)

Defined in: [src/primitives/TypedData/errors.js:9](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/TypedData/errors.js#L9)

###### Parameters

###### message

`string`

###### context?

`any`

###### Returns

[`InvalidTypedDataError`](#invalidtypeddataerror)

###### Overrides

`Error.constructor`

#### Properties

##### context

> **context**: `any`

Defined in: [src/primitives/TypedData/errors.js:12](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/TypedData/errors.js#L12)

##### name

> **name**: `string`

Defined in: [src/primitives/TypedData/errors.js:11](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/TypedData/errors.js#L11)

###### Inherited from

`Error.name`

## Type Aliases

### TypedDataField

> **TypedDataField** = `object`

Defined in: [src/primitives/TypedData/TypedDataType.ts:6](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/TypedData/TypedDataType.ts#L6)

EIP-712 Typed Data field definition

#### Properties

##### name

> `readonly` **name**: `string`

Defined in: [src/primitives/TypedData/TypedDataType.ts:7](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/TypedData/TypedDataType.ts#L7)

##### type

> `readonly` **type**: `string`

Defined in: [src/primitives/TypedData/TypedDataType.ts:8](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/TypedData/TypedDataType.ts#L8)

***

### TypedDataType

> **TypedDataType**\<`T`> = `object`

Defined in: [src/primitives/TypedData/TypedDataType.ts:16](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/TypedData/TypedDataType.ts#L16)

EIP-712 Typed Data structure

Complete structure for EIP-712 typed structured data signing

#### Type Parameters

##### T

`T` = `Record`\<`string`, `unknown`>

#### Properties

##### domain

> `readonly` **domain**: [`DomainType`](Domain.mdx#domaintype)

Defined in: [src/primitives/TypedData/TypedDataType.ts:22](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/TypedData/TypedDataType.ts#L22)

##### message

> `readonly` **message**: `T`

Defined in: [src/primitives/TypedData/TypedDataType.ts:23](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/TypedData/TypedDataType.ts#L23)

##### primaryType

> `readonly` **primaryType**: `string`

Defined in: [src/primitives/TypedData/TypedDataType.ts:21](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/TypedData/TypedDataType.ts#L21)

##### types

> `readonly` **types**: `object`

Defined in: [src/primitives/TypedData/TypedDataType.ts:17](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/TypedData/TypedDataType.ts#L17)

###### Index Signature

\[`key`: `string`]: readonly [`TypedDataField`](#typeddatafield)\[]

###### EIP712Domain

> `readonly` **EIP712Domain**: readonly [`TypedDataField`](#typeddatafield)\[]

## Functions

### \_encode()

> **\_encode**(`typedData`, `crypto`): `Uint8Array`\<`ArrayBufferLike`>

Defined in: [src/primitives/TypedData/encode.js:17](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/TypedData/encode.js#L17)

Encode EIP-712 typed data message

Returns the encoded message data (without domain separator)

#### Parameters

##### typedData

[`TypedDataType`](#typeddatatype)\<`Record`\<`string`, `unknown`>>

TypedData

##### crypto

Crypto dependencies

###### keccak256

(`data`) => `Uint8Array`

Keccak256 hash function

#### Returns

`Uint8Array`\<`ArrayBufferLike`>

Encoded message data

#### Example

```javascript theme={null}
const encoded = TypedData.encode(typedData, { keccak256 });
```

***

### \_from()

> **\_from**(`typedData`): [`TypedDataType`](#typeddatatype)\<`Record`\<`string`, `unknown`>>

Defined in: [src/primitives/TypedData/from.js:32](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/TypedData/from.js#L32)

Create TypedData from object

#### Parameters

##### typedData

TypedData object

###### domain

`object`

Domain separator

###### message

`any`

Message data

###### primaryType

`string`

Primary type name

###### types

`Record`\<`string`, readonly `TypedDataField`\[]>

Type definitions

#### Returns

[`TypedDataType`](#typeddatatype)\<`Record`\<`string`, `unknown`>>

TypedData

#### Throws

If typedData is invalid

#### Example

```javascript theme={null}
import * as TypedData from './primitives/TypedData/index.js';
const typedData = TypedData.from({
  types: {
    EIP712Domain: [{ name: 'name', type: 'string' }],
    Person: [{ name: 'name', type: 'string' }]
  },
  primaryType: 'Person',
  domain: { name: 'MyDApp' },
  message: { name: 'Alice' }
});
```

***

### \_hash()

> **\_hash**(`typedData`, `crypto`): [`HashType`](../index/namespaces/HashType.mdx#hashtype)

Defined in: [src/primitives/TypedData/hash.js:20](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/TypedData/hash.js#L20)

Compute EIP-712 typed data hash for signing

hash = keccak256("\x19\x01" || domainSeparator || messageHash)

#### Parameters

##### typedData

[`TypedDataType`](#typeddatatype)\<`Record`\<`string`, `unknown`>>

TypedData

##### crypto

Crypto dependencies

###### keccak256

(`data`) => `Uint8Array`

Keccak256 hash function

#### Returns

[`HashType`](../index/namespaces/HashType.mdx#hashtype)

Hash for signing

#### Example

```javascript theme={null}
import { keccak256 } from './crypto/Keccak256/index.js';
const hash = TypedData.hash(typedData, { keccak256 });
const signature = await wallet.signMessage(hash);
```

***

### \_validate()

> **\_validate**(`typedData`): `void`

Defined in: [src/primitives/TypedData/validate.js:14](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/TypedData/validate.js#L14)

Validate EIP-712 typed data structure

#### Parameters

##### typedData

[`TypedDataType`](#typeddatatype)\<`Record`\<`string`, `unknown`>>

TypedData

#### Returns

`void`

#### Throws

If validation fails

#### Example

```javascript theme={null}
TypedData.validate(typedData); // throws if invalid
```

***

### encode()

> **encode**(`typedData`, `crypto`): `Uint8Array`

Defined in: [src/primitives/TypedData/index.ts:45](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/TypedData/index.ts#L45)

#### Parameters

##### typedData

[`TypedDataType`](#typeddatatype)\<`Record`\<`string`, `unknown`>>

##### crypto

###### keccak256

(`data`) => `Uint8Array`

#### Returns

`Uint8Array`

***

### from()

> **from**\<`T`>(`typedData`): [`TypedDataType`](#typeddatatype)\<`T`>

Defined in: [src/primitives/TypedData/index.ts:16](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/TypedData/index.ts#L16)

#### Type Parameters

##### T

`T` = `Record`\<`string`, `unknown`>

#### Parameters

##### typedData

###### domain

\{ `chainId?`: `number` | [`ChainIdType`](ChainId.mdx#chainidtype); `name?`: `string`; `salt?`: `string` | [`HashType`](../index/namespaces/HashType.mdx#hashtype); `verifyingContract?`: `string` | [`AddressType`](Address.mdx#addresstype); `version?`: `string`; }

###### domain.chainId?

`number` | [`ChainIdType`](ChainId.mdx#chainidtype)

###### domain.name?

`string`

###### domain.salt?

`string` | [`HashType`](../index/namespaces/HashType.mdx#hashtype)

###### domain.verifyingContract?

`string` | [`AddressType`](Address.mdx#addresstype)

###### domain.version?

`string`

###### message

`T`

###### primaryType

`string`

###### types

\{\[`key`: `string`]: readonly [`TypedDataField`](#typeddatafield)\[]; `EIP712Domain`: readonly [`TypedDataField`](#typeddatafield)\[]; }

###### types.EIP712Domain

readonly [`TypedDataField`](#typeddatafield)\[]

#### Returns

[`TypedDataType`](#typeddatatype)\<`T`>

***

### hash()

> **hash**(`typedData`, `crypto`): [`HashType`](../index/namespaces/HashType.mdx#hashtype)

Defined in: [src/primitives/TypedData/index.ts:36](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/TypedData/index.ts#L36)

#### Parameters

##### typedData

[`TypedDataType`](#typeddatatype)\<`Record`\<`string`, `unknown`>>

##### crypto

###### keccak256

(`data`) => `Uint8Array`

#### Returns

[`HashType`](../index/namespaces/HashType.mdx#hashtype)

***

### validate()

> **validate**(`typedData`): `void`

Defined in: [src/primitives/TypedData/index.ts:54](https://github.com/evmts/voltaire/blob/bd6ec34405c15ad8cd51d11579d495dc53813482/src/primitives/TypedData/index.ts#L54)

#### Parameters

##### typedData

[`TypedDataType`](#typeddatatype)\<`Record`\<`string`, `unknown`>>

#### Returns

`void`
