createSelfAndGasless() keeps custody with the trader EOA but submits trades through a Safe smart account.
- the trader EOA owns USDC and positions
- the trader EOA signs the underlying trade action
- the trader’s Safe submits the transaction as a sponsored user operation
When to use it
- consumer apps that want a gasless UX
- embedded trading flows where the user should not need ETH after setup
- client-side apps that already have a Safe execution path
One-time setup
The trader must do two EOA-signed transactions once:Submit-capable client
Build-only client
get*Tx() returns a Safe-style request with safeAddress and calls.
Parameters
| Field | Type | Required | Notes |
|---|---|---|---|
traderPrivateKey | 0x${string} | Submit-capable | Trader EOA key. A Safe is derived from it to relay trades gaslessly. |
traderAddress | 0x${string} | Build-only | Trader EOA address. |
safeAddress | 0x${string} | Build-only | Safe that submits delegated calls. |
pimlicoUrl | string | Optional | Bundler/paymaster URL. Defaults to the Ostium sponsor URL (chain-aware). |
rpcUrl | string | Optional | RPC URL for reads/simulation. Defaults to the public RPC. |
sponsorshipPolicyId | string | Optional | Pimlico sponsorship policy ID. |
testnet, slippageBps, builder, subgraphUrl, builderApiUrl, alchemyApiKey). See Client Configuration.