# EIP 712 Type Definitions

All EIP-712 types used by Lynx 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 every write endpoint except the four in Method B.

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

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

## Method B — Direct Typed Structs

Used by the four 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)
```

## 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:///1548985/authentication-and-signing/signing-method-a.md) and [Signing Method B](file:///1548985/authentication-and-signing/signing-method-b.md) for full Python + Node code samples.


---

# Agent Instructions: 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.lynxtrade.world/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.
