> For the complete documentation index, see [llms.txt](https://docs.symm.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.symm.io/trader-documentation/building-a-trading-bot/part-1-one-time-on-chain-setup/delegate-the-session-key.md).

# Delegate the session key

Session keys are how you avoid wallet popups on every trade. Generate an ephemeral keypair, give it on-chain authority to sign for your sub-account for some bounded time window, and then let it sign all the EIP-712 trade messages off-chain. The [InstantLayer](/trader-documentation/how-trading-works-in-symmio/instant-trading.md#the-instant-layer) verifies these delegations on every `executeBatch` / `executeTemplate` call: when your session key's signature recovers, the InstantLayer checks that the calldata's selector is in the active delegated set for `(sub, sessionKey)`.

**Signed by.** Owner EOA. The call goes to the InstantLayer.

**Function.** `grantDelegation(DelegationInfo info)`, where `DelegationInfo` is:

```
struct DelegationInfo {
    Account  account;            // (subAccount, isPartyB=false)
    address  delegatedSigner;    // the session key's address
    bytes4[] selectors;          // what they're allowed to sign for
    uint256  expiryTimestamp;    // unix seconds
}
```

The selectors are where this gets subtle. You need five of them:

| Selector     | Meaning                                                         |
| ------------ | --------------------------------------------------------------- |
| `0xa6d66852` | `addMarginToNextVA`: pre-funding a VA before opening a position |
| `0xa7f3b34b` | `sendQuoteWithAffiliateAndData`: opening a position             |
| `0x501e891f` | `requestToClosePosition`: closing a position                    |
| `0xeaa31b19` | ID the COH (TP/SL service) keys delegations under               |
| `0x00000001` | ID services use to verify session-key auth                      |

The first three are real Symmio function selectors, and the InstantLayer checks them on every `executeBatch`. The last two are four-byte tags the off-chain services use as lookup keys when they answer "is this session key authorized to talk to me?"&#x20;

{% hint style="info" %}
**Note.** The `grantDelegation` tx is sent from your owner EOA, but once it lands, the *session key* (not the EOA) is what signs all subsequent EIP-712 messages on the trade path.
{% endhint %}


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.symm.io/trader-documentation/building-a-trading-bot/part-1-one-time-on-chain-setup/delegate-the-session-key.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
