Skip to content

Commit 542ce20

Browse files
committed
Update example.
Signed-off-by: bgravenorst <byron.gravenorst@consensys.net>
1 parent 9982fb4 commit 542ce20

File tree

1 file changed

+31
-24
lines changed

1 file changed

+31
-24
lines changed

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

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ 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-
- `stateOverride`: _\[optional]_ Object that contains the address-to-state mapping to [override state values](#override-state-values)
44+
- `stateOverride`: _\[optional]_ Object that contains the address-to-state mapping to [override state values](#override-state-values).
4545
Each entry specifies a state that will be temporarily overridden before executing the call:
4646
- `balance`: _\[optional]_ Hexadecimal of the temporary account balance for the call execution.
4747
- `nonce`: _\[optional]_ Hexadecimal of the temporary nonce value for the call execution.
@@ -99,32 +99,39 @@ Replace `<YOUR-API-KEY>` with an API key from your [MetaMask Developer dashboard
9999

100100
## Override state values
101101

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.
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.
105104

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:
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.
108110

109111
```json
110112
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
113+
-X POST \
114+
-H "Content-Type: application/json" \
115+
-d '{
116+
"jsonrpc":"2.0",
117+
"method":"linea_estimateGas",
118+
"params":[
119+
{
120+
"from":"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73",
121+
"to":"0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f",
122+
"data":"0xa9059cbb000000000000000000000000627306090abaB3A6e1400e9345bC60c78a8BEf570000000000000000000000000000000000000000000000001bc16d674ec80000"
123+
},
124+
{
125+
"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73": {
126+
"balance": "0x16345785d8a0000"
127+
},
128+
"0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f": {
129+
"stateDiff":{
130+
"0x2d206e5210c119b1cbed144f517f1f1dfd586eed26793a233e6afc261f4cf97f":"0x0000000000000000000000000000000000000000000000001bc16d674ec80000"
131+
}
132+
}
133+
}
134+
],
135+
"id":53
129136
}'
130137
```

0 commit comments

Comments
 (0)