Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/base-account/improve-ux/batch-transactions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,13 @@ async function trackBatchTransaction(

You can learn more about `wallet_getCallsStatus` in the [reference documentation](/base-account/reference/core/provider-rpc-methods/wallet_getCallsStatus).

<Tip>
**Need more control over gas?**

You can override the gas limit for individual calls in a batch using the [`gasLimitOverride`](/base-account/reference/core/capabilities/gasLimitOverride) capability. This is useful for calls with nondeterministic gas consumption, such as swaps. See the [capabilities overview](/base-account/reference/core/capabilities/overview) for the full list of supported capabilities.

</Tip>

## Video Guide

<iframe
Expand Down
199 changes: 199 additions & 0 deletions docs/base-account/reference/core/capabilities/gasLimitOverride.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
---
title: "gasLimitOverride"
description: "Override gas limits for individual calls in a wallet_sendCalls batch"
---

Defined in [ERC-8132](https://github.com/ethereum/ERCs/pull/1485)

<Info>
The gasLimitOverride capability allows apps to specify gas limits for individual calls within a `wallet_sendCalls` batch. Gas limits can be partially specified — you can provide overrides for only the calls you have context about, and the wallet estimates gas for the rest. Apps often have more context about the gas requirements of their own contract calls than the wallet, making app-provided gas limits more accurate.
</Info>

## Parameters

This is a **call-level capability**, meaning it is specified on individual calls within a `wallet_sendCalls` batch rather than at the top level.

<ParamField body="value" type="`0x${string}`" required>
Hex-encoded gas limit for the call. Must be a non-zero value that does not exceed the block gas limit of the target chain.
</ParamField>

## Returns

<ResponseField name="gasLimitOverride" type="object">
The gasLimitOverride capability configuration.

<Expandable title="gasLimitOverride capability properties">
<ResponseField name="supported" type="boolean">
Indicates whether the wallet supports app-provided gas limit overrides. Reported for all chains (`0x0`) when supported.
</ResponseField>
</Expandable>
</ResponseField>

## Example usage

<RequestExample>
```typescript Check gasLimitOverride support
const capabilities = await provider.request({
method: 'wallet_getCapabilities',
params: [userAddress]
});

const gasLimitOverrideSupport = capabilities["0x0"]?.gasLimitOverride;
```

```typescript Send calls with a gas limit override
const result = await provider.request({
method: "wallet_sendCalls",
params: [{
version: "1.0",
chainId: "0x2105",
from: userAddress,
atomicRequired: true,
calls: [
{
// Approval — no override, wallet estimates gas
to: tokenAddress,
value: "0x0",
data: approveCallData
},
{
// Swap — app provides a known gas limit
to: swapContractAddress,
value: "0x0",
data: swapCallData,
capabilities: {
gasLimitOverride: {
value: "0x30D40" // 200,000 gas
}
}
}
]
}]
});
```
</RequestExample>

<ResponseExample>
```json Capability response (supported)
{
"0x0": {
"gasLimitOverride": {
"supported": true
}
}
}
```

```json Capability response (unsupported)
{
"0x0": {
"gasLimitOverride": {
"supported": false
}
}
}
```
</ResponseExample>

## Error handling

| Code | Message | Description |
| ------ | -------------------- | --------------------------------------------------------------------------- |
| -32602 | Invalid params | Gas limit is zero or exceeds the block gas limit of the target chain |
| 5700 | Capability required | Call includes gasLimitOverride but wallet doesn't support it |

## How it works

When a wallet receives calls with `gasLimitOverride` capabilities:

1. The wallet uses the app-provided gas limit for that call's portion of the batch gas limit.
2. For calls **without** a `gasLimitOverride`, the wallet estimates gas as usual.
3. The wallet may add additional gas to account for batch processing overhead (such as smart account execution or EIP-7702 delegation).

This is a call-level capability, so you can specify gas limits for only some calls in a batch. The wallet handles estimation for the rest.

## Use cases

### Nondeterministic gas usage

Some contract calls have nondeterministic gas costs that are difficult for wallets to estimate accurately. Apps with deep knowledge of their contracts can provide better gas limits:

```typescript
// A complex DeFi operation where gas usage depends on pool state
const result = await provider.request({
method: "wallet_sendCalls",
params: [{
version: "1.0",
chainId: "0x2105",
from: userAddress,
atomicRequired: true,
calls: [
{
to: routerAddress,
value: "0x0",
data: swapCallData,
capabilities: {
gasLimitOverride: {
value: "0x7A120" // 500,000 gas — app knows the swap is complex
}
}
}
]
}]
});
```

### Partial gas limit specification

You can specify gas limits for only the calls you have context about and let the wallet estimate the rest:

```typescript
const result = await provider.request({
method: "wallet_sendCalls",
params: [{
version: "1.0",
chainId: "0x2105",
from: userAddress,
atomicRequired: true,
calls: [
{
// Approval — let the wallet estimate gas
to: tokenAddress,
value: "0x0",
data: approveCallData
},
{
// Swap — app provides a known gas limit
to: swapContractAddress,
value: "0x0",
data: swapCallData,
capabilities: {
gasLimitOverride: {
value: "0x30D40" // 200,000 gas
}
}
}
]
}]
});
```

## Best practices

1. **Check capabilities first**: Verify `gasLimitOverride` support via `wallet_getCapabilities` before including it in calls
2. **Use `optional: true` for compatibility**: Mark the capability as optional if your app can function without it, so wallets that don't support it can still process the batch
3. **Provide accurate limits**: Use gas limits based on your contract's actual requirements — overly tight limits cause reverts, overly generous limits waste block space
4. **Let the wallet handle overhead**: Only specify gas for the call itself. The wallet accounts for batch processing overhead separately

<Warning>
The wallet returns an invalid params error (`-32602`) if a provided gas limit is zero or exceeds the block gas limit of the target chain.
</Warning>

## Related capabilities

- [atomic](/base-account/reference/core/capabilities/atomic) - Use with atomic batch transactions
- [paymasterService](/base-account/reference/core/capabilities/paymasterService) - Combine with sponsored transactions

import PolicyBanner from "/snippets/PolicyBanner.mdx";

<PolicyBanner />
2 changes: 2 additions & 0 deletions docs/base-account/reference/core/capabilities/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const baseCapabilities = capabilities["0x2105"]; // Base mainnet chain ID
| [flowControl](/base-account/reference/core/capabilities/flowControl) | `wallet_sendCalls` | Flow control |
| [datacallback](/base-account/reference/core/capabilities/datacallback) | `wallet_sendCalls` | Data callback |
| [dataSuffix](/base-account/reference/core/capabilities/dataSuffix) | `wallet_sendCalls` | Transaction attribution |
| [gasLimitOverride](/base-account/reference/core/capabilities/gasLimitOverride) | `wallet_sendCalls` | Call-level gas limit overrides |

## Using with wallet_connect

Expand Down Expand Up @@ -201,6 +202,7 @@ For detailed information on each capability:
- [auxiliaryFunds](/base-account/reference/core/capabilities/auxiliaryFunds) - Auxiliary funding support
- [atomic](/base-account/reference/core/capabilities/atomic) - Atomic batch transactions
- [paymasterService](/base-account/reference/core/capabilities/paymasterService) - Gasless transactions
- [gasLimitOverride](/base-account/reference/core/capabilities/gasLimitOverride) - Call-level gas limit overrides

## Related Methods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ Whether data callbacks are supported for this account on this chain.
</ResponseField>
</Expandable>
</ResponseField>

<ResponseField name="gasLimitOverride" type="object">
Indicates support for app-provided gas limit overrides on individual calls. Defined in [ERC-8132](https://github.com/ethereum/ERCs/pull/1485). Reported for all chains (`0x0`).

<Expandable title="gasLimitOverride properties">
<ResponseField name="supported" type="boolean">
Whether gas limit overrides are supported.
</ResponseField>
</Expandable>
</ResponseField>
</Expandable>
</ResponseField>
</Expandable>
Expand Down Expand Up @@ -108,11 +118,13 @@ const baseCapabilities = capabilities["0x2105"]; // Base Mainnet
const hasAuxiliaryFunds = baseCapabilities?.auxiliaryFunds?.supported;
const supportsAtomic = baseCapabilities?.atomic?.supported === "supported";
const hasPaymaster = baseCapabilities?.paymasterService?.supported;
const hasGasLimitOverride = capabilities["0x0"]?.gasLimitOverride?.supported;

console.log('Capabilities:', {
hasAuxiliaryFunds,
supportsAtomic,
hasPaymaster
hasPaymaster,
hasGasLimitOverride
});
```
</RequestExample>
Expand Down Expand Up @@ -140,6 +152,11 @@ console.log('Capabilities:', {
"supported": false
}
},
"0x0": {
"gasLimitOverride": {
"supported": true
}
},
"0x14A34": {
"auxiliaryFunds": {
"supported": false
Expand Down Expand Up @@ -212,7 +229,8 @@ async function getWalletCapabilities(userAddress: string) {
hasAtomicBatch: baseCapabilities.atomic?.supported === "supported",
hasPaymaster: !!baseCapabilities.paymasterService?.supported,
hasFlowControl: !!baseCapabilities.flowControl?.supported,
hasDataCallback: !!baseCapabilities.datacallback?.supported
hasDataCallback: !!baseCapabilities.datacallback?.supported,
hasGasLimitOverride: !!capabilities["0x0"]?.gasLimitOverride?.supported
};
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ The value to send with the call (in wei, hex format).
<ParamField body="data" type="string">
The call data (optional, hex format).
</ParamField>

<ParamField body="capabilities" type="object">
Optional call-level capabilities. For example, [`gasLimitOverride`](/base-account/reference/core/capabilities/gasLimitOverride) allows you to specify a gas limit for an individual call.
</ParamField>
</Expandable>
</ParamField>

Expand Down Expand Up @@ -87,6 +91,42 @@ An object containing information about the sent batch, including transaction det
}]
}
```

```json Request with call-level gas limit overrides
{
"id": 1,
"jsonrpc": "2.0",
"method": "wallet_sendCalls",
"params": [{
"version": "2.0.0",
"from": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
"chainId": "0x2105",
"atomicRequired": true,
"calls": [
{
"to": "0x54f1C1965B355e1AB9ec3465616136be35bb5Ff7",
"value": "0x0",
"data": "0x095ea7b3...",
"capabilities": {
"gasLimitOverride": {
"value": "0x13880"
}
}
},
{
"to": "0x2D48e6f5Ae053e4E918d2be53570961D880905F2",
"value": "0x0",
"data": "0x38ed1739...",
"capabilities": {
"gasLimitOverride": {
"value": "0x30D40"
}
}
}
]
}]
}
```
</RequestExample>

<ResponseExample>
Expand Down
3 changes: 2 additions & 1 deletion docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@
"base-account/reference/core/capabilities/paymasterService",
"base-account/reference/core/capabilities/auxiliaryFunds",
"base-account/reference/core/capabilities/datacallback",
"base-account/reference/core/capabilities/dataSuffix"
"base-account/reference/core/capabilities/dataSuffix",
"base-account/reference/core/capabilities/gasLimitOverride"
]
}
]
Expand Down
Loading