Skip to content

Configuration

Both OxGasAuth and OxGasClient accept a configuration object when you create them. Only apiKey is required — the rest have sensible defaults.

OptionTypeDefaultDescription
apiKeystringrequiredYour project API key from the dashboard.
widgetUrlstring0xGasless CDNOverride with a custom widget URL. Useful for self-hosted setups or local development.
networkstring"Ethereum"The network name shown in the widget’s approval screens.
chainIdnumberPass a chain ID and the SDK looks up the name automatically. Takes precedence over network if both are provided.
zIndexnumber99999The CSS z-index of the widget overlay. Raise this if other elements appear on top of the widget.
loginTimeoutnumber300000How long (in milliseconds) to wait for the user to complete login before rejecting. Default is 5 minutes.
signTimeoutnumber120000How long (in milliseconds) to wait for the user to approve a signing request. Default is 2 minutes.
debugbooleanfalseEnables detailed console logging. Turn this on during development to trace message flow between your app and the widget.

OxGasClient adds three more options on top of the above:

OptionTypeDefaultDescription
bundlerUrlstringrequiredThe bundler endpoint that receives your UserOperations.
paymasterUrlstringrequiredThe paymaster RPC URL used to sponsor gas.
rpcUrlstringchain defaultA custom RPC for reading on-chain state (balances, token info). If omitted, a default public RPC is used.
accountIndexnumber0Derive a different smart account from the same signer by passing a non-zero index.
import { OxGasAuth } from '0xgas-auth';
const auth = new OxGasAuth({
apiKey: 'your-api-key',
chainId: 8453, // Base — resolved to "Base" in the widget
});

If you only need the API key and are happy with all defaults, you can pass a string directly:

const auth = new OxGasAuth('your-api-key');
import { OxGasClient } from '0xgas-auth';
const client = new OxGasClient({
apiKey: 'your-api-key',
chainId: 137,
bundlerUrl: 'https://bundler.0xgasless.com/137',
paymasterUrl: 'https://paymaster.0xgasless.com/v1/137/rpc/your-api-key',
rpcUrl: 'https://polygon-rpc.com',
debug: true,
loginTimeout: 600_000, // 10 minutes
});

When working on the widget itself or running a self-hosted instance:

const auth = new OxGasAuth({
apiKey: 'dev-key',
widgetUrl: 'http://localhost:5173',
debug: true,
});

For chains not in the built-in registry, or when you want a specific display name:

const auth = new OxGasAuth({
apiKey: 'your-api-key',
network: 'My Custom L2',
});

When you pass chainId, the SDK resolves it to a human-readable name for the widget’s approval screens. For example, chainId: 42161 becomes "Arbitrum One". If the chain ID is not in the built-in list, it falls back to "Chain 42161".

You can override this at any time by passing network explicitly. The explicit network value always wins.

See Supported Networks for the full list of built-in chain IDs.