You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: services/reference/linea/json-rpc-methods/linea_estimategas.mdx
+46-6Lines changed: 46 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ We recommend using `linea_estimateGas` for more accurate results.
30
30
31
31
## Parameters
32
32
33
-
-`TRANSACTION CALL OBJECT`_\[required]_
33
+
-`call`:_\[required]_ Transaction call object:
34
34
-`from`: _\[optional]_ 20 bytes - The address the transaction is sent from.
35
35
-`to`: _\[optional]_ 20 bytes - The address the transaction is directed to.
36
36
-`gas`: _\[optional]_ Hexadecimal value of the gas provided for the transaction execution. `linea_estimateGas` consumes
@@ -41,11 +41,12 @@ We recommend using `linea_estimateGas` for more accurate results.
41
41
-`value`: _\[optional]_ Hexadecimal value of the value sent with this transaction.
42
42
-`data`: _\[optional]_ Hash of the method signature and encoded parameters. See the
43
43
[Ethereum contract ABI specification](https://docs.soliditylang.org/en/latest/abi-spec.html).
44
-
-`blockParameter`: (string) [_optional_] A hexadecimal block number, or one of the tags `latest`, `earliest`, `pending` or `finalized`. See the [default block parameter](https://ethereum.org/en/developers/docs/apis/json-rpc/#default-block).
45
-
:::warning
46
-
`safe` isn't supported. Use `finalized` instead.
47
-
Learn more about [Linea's layer 2 finalization](https://docs.linea.build/developers/guides/finalized-block).
48
-
:::
44
+
-`stateOverride`: _\[optional]_ Object that contains the address-to-state mapping to [override state values](#override-state-values).
45
+
Each entry specifies a state that will be temporarily overridden before executing the call:
46
+
-`balance`: _\[optional]_ Hexadecimal value of the temporary account balance for the call execution.
47
+
-`nonce`: _\[optional]_ Hexadecimal value of the temporary nonce for the call execution.
48
+
-`code` : _\[optional]_ Bytecode to inject into the account.
49
+
-`stateDiff`: `key:value` pairs to override individual slots in the account storage.
49
50
50
51
## Returns
51
52
@@ -95,3 +96,42 @@ Replace `<YOUR-API-KEY>` with an API key from your [MetaMask Developer dashboard
95
96
```
96
97
</TabItem>
97
98
</Tabs>
99
+
100
+
## Override state values
101
+
102
+
You can override an account with temporary state values before making the call. This allows you to
103
+
make temporary state changes without affecting the actual blockchain state.
104
+
105
+
The following example estimates the cost for transferring an ERC-20 token for an account which does not
106
+
have the required assets onchain.
107
+
108
+
The example sets a custom ETH balance for the sender (to cover gas costs) and modifies the account's
109
+
balance within the ERC-20 contract's storage for the duration of the call.
0 commit comments