> For the complete documentation index, see [llms.txt](https://docs.unix.market/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.unix.market/reference/eip-712-type-definitions.md).

# EIP-712 Type Definitions

All EIP-712 types used by UniX writes. The Domain is shared across both signing methods.

## Domain

```json
{
  "name": "UniX",
  "version": "1",
  "chainId": 1
}
```

EIP-712 domain type: `EIP712Domain(string name,string version,uint256 chainId)` — no `verifyingContract`.

## Method A — Agent (Default)

Used by default for trading, account settings, transfer, and withdrawal writes. The Method B operations below do not use `actionHash`.

```
Agent(address sender, bytes32 actionHash, uint64 nonce, uint64 expiresAfter)
```

See [Signing Method A](file:///3824019/authentication/signing-method-a-actionhash.md) for how `actionHash` is computed.

## Method B — Direct Typed Structs

Used by account-relationship endpoints.

### ApproveAgent

```
ApproveAgent(address sender, address agentAddress, address authorizedAddress,
             uint32 validDays, string label, uint64 nonce, uint64 expiresAfter)
```

### RevokeAgent

```
RevokeAgent(address sender, address agentAddress, uint64 nonce, uint64 expiresAfter)
```

### RenewAgent

```
RenewAgent(address sender, address agentAddress, uint32 validDays, uint64 nonce, uint64 expiresAfter)
```

### CreateSubAccount

```
CreateSubAccount(address sender, string label, uint64 nonce, uint64 expiresAfter)
```

### AssociateAccount

```
AssociateAccount(address sender, address mainAddress, uint64 nonce, uint64 expiresAfter)
```

## Type Encoding Rules

| Solidity type | Encoded as                                                   |
| ------------- | ------------------------------------------------------------ |
| `address`     | 20 bytes, right-aligned in a 32-byte slot, left-zero-padded. |
| `uint32`      | 4 bytes big-endian, right-aligned in a 32-byte slot.         |
| `uint64`      | 8 bytes big-endian, right-aligned in a 32-byte slot.         |
| `bytes32`     | Used as-is.                                                  |
| `string`      | `keccak256(utf8_bytes(value))` (32 bytes).                   |

## `signing_hash` Formula

```
typeHash      = keccak256(encodeType_string)
structHash    = keccak256(typeHash ‖ encoded_field_1 ‖ encoded_field_2 ‖ …)
domainSeparator = keccak256(
    keccak256("EIP712Domain(string name,string version,uint256 chainId)")
    ‖ keccak256("UniX")
    ‖ keccak256("1")
    ‖ pad32(chainId)
)
signing_hash  = keccak256("\x19\x01" ‖ domainSeparator ‖ structHash)
```

The `signing_hash` is both the input to ECDSA signing and the on-chain `tx_hash`.

## Reference Implementations

| Language          | Library       | Function                                                                          |
| ----------------- | ------------- | --------------------------------------------------------------------------------- |
| Python            | `eth_account` | `encode_typed_data(domain, types, primaryType, message)` → `Account.sign_message` |
| Node / TypeScript | `ethers` v6   | `wallet.signTypedData(domain, types, message)`                                    |
| Go                | `go-ethereum` | `signer/core/apitypes` + `crypto.Sign`                                            |
| Rust              | `ethers-rs`   | `LocalWallet::sign_typed_data`                                                    |

See [Signing Method A](file:///3824019/authentication/signing-method-a-actionhash.md) and [Signing Method B](file:///3824019/authentication/signing-method-b-typed-data.md) for full Python + Node code samples.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.unix.market/reference/eip-712-type-definitions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
