Skip to content

Commit

Permalink
Add viem example to linea_estimateGas reference (#772)
Browse files Browse the repository at this point in the history
* Add viem example

* Fix indentation
  • Loading branch information
jlwllmr authored Oct 10, 2024
1 parent 7661d47 commit 0e7f5fe
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docs/developers/reference/api/linea-estimategas.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,33 @@ You can also call the API using [Infura's supported Linea endpoints](https://doc
console.log(fees);
```
</TabItem>
<TabItem value="viem">
```javascript
import { createPublicClient, http, parseEther } from 'viem'
import { linea } from 'viem/chains'
import { estimateGas } from 'viem/linea'
async function EstimateGas() {
const client = createPublicClient({
chain: linea,
transport: http(),
});
try {
const gasEstimate = await estimateGas(client, {
account: '0x...', // Source account's address
to: '0x...', // Destination account's address
value: parseEther('0.004') // Amount of ETH to transfer
});
console.log('Gas Estimate:', gasEstimate);
} catch (error) {
console.error('Error estimating gas:', error);
}
}
EstimateGas();
```
</TabItem>
</Tabs>
### Response
Expand Down

0 comments on commit 0e7f5fe

Please sign in to comment.