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

# Delegated + Self

> Backend-controlled delegated execution where a delegate EOA signs and pays gas on behalf of a trader.

`createDelegatedAndSelf()` separates the trader from the executor.

* the trader EOA owns USDC and positions
* a delegate EOA signs each action
* the delegate EOA submits the transaction and pays gas

## When to use it

* backend systems trading on behalf of users
* managed execution products
* integrations where users keep custody but your server handles submission

## One-time trader setup

Before this mode can trade, the trader must:

```ts theme={null}
await traderClient.approveUsdc('max');
await traderClient.setDelegate('0xDelegateAddress');
```

## Submit-capable client

```ts theme={null}
const client = await OstiumClient.createDelegatedAndSelf({
  delegatePrivateKey: process.env.DELEGATE_PRIVATE_KEY as `0x${string}`,
  traderAddress: '0xTraderAddress',
  rpcUrl: process.env.ARB_RPC_URL!,
});
```

## Build-only client

```ts theme={null}
const client = await OstiumClient.createDelegatedAndSelf({
  traderAddress: '0xTraderAddress',
  delegateAddress: '0xDelegateAddress',
});
```

In build-only mode, `get*Tx()` returns an EOA request whose calldata is already wrapped for delegated execution.

## Parameters

| Field                | Type          | Required                                | Notes                                                                          |
| -------------------- | ------------- | --------------------------------------- | ------------------------------------------------------------------------------ |
| `delegatePrivateKey` | `0x${string}` | Submit-capable                          | Delegate EOA key. Signs and pays gas.                                          |
| `traderAddress`      | `0x${string}` | Yes                                     | Trader the delegate acts for. Must have called `setDelegate(delegateAddress)`. |
| `delegateAddress`    | `0x${string}` | Build-only                              | Delegate EOA that will submit the transaction.                                 |
| `rpcUrl`             | `string`      | Submit-capable; optional for build-only | Arbitrum RPC URL. Build-only defaults to the public RPC.                       |

Plus the shared options (`testnet`, `slippageBps`, `builder`, `subgraphUrl`, `builderApiUrl`, `alchemyApiKey`). See [Client Configuration](/developer/client-modes/configuration).
