# Smart wallets

Every trade on HermesTrade is a blockchain transaction on Monad. In a conventional setup, each transaction would require your wallet to hold native tokens and pay gas. For a trading platform — where you might place, adjust, and cancel dozens of orders in a session — that UX is impractical. HermesTrade solves this with **Safe smart wallets** and a **Relayer** that covers gas on your behalf.

***

## Your Safe wallet

When you connect to HermesTrade, a **Safe smart wallet** is deployed on Monad for your account. This is your wallet on HermesTrade — you are the sole owner and have complete control over the funds it holds at all times.

Your Safe wallet holds your USDW collateral and outcome shares, and is the `maker` address on every order you place. Its address is stored as `proxyWallet` in the Gamma API `Profile` schema.

Your connected wallet (MetaMask, WalletConnect, or any EIP-712-compatible signer) is used only for signing — it never sends transactions or pays gas on HermesTrade.

***

## How the Relayer works

The Relayer is HermesTrade's gas abstraction service. When you take any action that requires an on-chain transaction, the flow is:

{% stepper %}
{% step %}

### Construct the Safe transaction

The application builds the transaction payload — for example, the calldata for placing an order on the CLOB exchange contract.
{% endstep %}

{% step %}

### Sign with EIP-712 (no gas cost)

Your EOA signs the transaction data using EIP-712. This is a signature, not a transaction — it costs nothing and happens instantly in your wallet.
{% endstep %}

{% step %}

### Submit to the Relayer

The application calls `POST /submit` on the Relayer API with the signed payload. The `SubmitRequest` body includes your `from` (EOA), `proxyWallet`, encoded `data`, and the `signature`.
{% endstep %}

{% step %}

### Relayer broadcasts and covers gas

The Relayer wraps your signed payload into a real Monad transaction, pays the gas fee, and submits it to the network. You receive a `transactionID` to track progress.
{% endstep %}
{% endstepper %}

Track the transaction status with `GET /transaction?id=<transactionID>`. The `RelayerTransaction.state` field reflects the current state.

***

## Smart wallet deployment

On your first interaction with HermesTrade, a Safe contract must be deployed for your EOA. The application checks this with:

```
GET /deployed?address=<eoaAddress>
```

**`DeployedResponse`:**

```
deployed    boolean   — true if the Safe is already on-chain
address     string    — your proxyWallet address
```

If `deployed: false`, the application submits a deployment transaction through the Relayer. Once deployed, your `proxyWallet` address is fixed — it does not change.

***

## scopeId

The Relayer and CLOB authentication headers both support an optional `PRED_SCOPE_ID` value. This is a tenant identifier used in whitelabel integrations, where a third-party application embeds HermesTrade trading under its own brand. Individual traders using the main HermesTrade app do not need to set this.

***

## Custody and security

Your Safe wallet's signing authority derives from your EOA private key — the same key you use to sign orders and authenticate. HermesTrade does not hold your keys or control your wallet. As the sole owner of your `proxyWallet`, you retain complete self-custody of all assets it holds.

{% hint style="info" %}
Because the Relayer pays gas on your behalf, you do not need to hold MON (Monad's native token) to trade. Collateral for trading is held in your `proxyWallet` in the platform's collateral token.
{% endhint %}


---

# 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.hermestrade.xyz/core-concepts/smart-wallets.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.
