Skip to content

Commit 51c4570

Browse files
committed
Add state overrides.
Signed-off-by: bgravenorst <byron.gravenorst@consensys.net>
1 parent cdd6aa3 commit 51c4570

File tree

1 file changed

+39
-6
lines changed

1 file changed

+39
-6
lines changed

services/reference/linea/json-rpc-methods/linea_estimategas.mdx

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ We recommend using `linea_estimateGas` for more accurate results.
3030

3131
## Parameters
3232

33-
- `TRANSACTION CALL OBJECT` _\[required]_
33+
- `call`: _\[required]_ Transaction call object:
3434
- `from`: _\[optional]_ 20 bytes - The address the transaction is sent from.
3535
- `to`: _\[optional]_ 20 bytes - The address the transaction is directed to.
3636
- `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.
4141
- `value`: _\[optional]_ Hexadecimal value of the value sent with this transaction.
4242
- `data`: _\[optional]_ Hash of the method signature and encoded parameters. See the
4343
[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 of the temporary account balance for the call execution.
47+
- `nonce`: _\[optional]_ Hexadecimal of the temporary nonce value 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.
4950

5051
## Returns
5152

@@ -95,3 +96,35 @@ Replace `<YOUR-API-KEY>` with an API key from your [MetaMask Developer dashboard
9596
```
9697
</TabItem>
9798
</Tabs>
99+
100+
## Override state values
101+
102+
You can to override an account with temporary state values before
103+
making the call. This allows you to make temporary state changes without affecting the actual
104+
blockchain state.
105+
106+
For example, here we'll override the balance of account `0xfe3b557e8fb62b89f4916b721be55ceb828dbd73`
107+
to ensure it has sufficient funds to estimate transferring ETH to the specified account:
108+
109+
```json
110+
curl https://linea-mainnet.infura.io/v3/<YOUR-API-KEY> \
111+
-X POST \
112+
-H "Content-Type: application/json" \
113+
-d '{
114+
"jsonrpc":"2.0",
115+
"method":"linea_estimateGas",
116+
"params":[
117+
{
118+
"from":"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73",
119+
"to":"0x627306090abaB3A6e1400e9345bC60c78a8BEf57",
120+
"value":"0xDE0B6B3A7640000"
121+
},
122+
{
123+
"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73": {
124+
"balance": "0x4563918244F40000"
125+
}
126+
}
127+
],
128+
"id":53
129+
}'
130+
```

0 commit comments

Comments
 (0)