Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added user op gas offset example to "Utilities" dir #279

Merged
merged 3 commits into from
May 14, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/tutorials/utils/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
sidebar_position: 11
title: Utilities

---

The following tutorials provide a detailed, step-by-step guide on how to use Biconomy SDK utility methods.

```mdx-code-block
import DocCardList from '@theme/DocCardList';

<DocCardList />
```
41 changes: 41 additions & 0 deletions docs/tutorials/utils/offsetGasValues.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
sidebar_label: "Offset Gas Values"
sidebar_position: 1
title: "Offset User Operation Gas Values"
---

import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";

### Overview

This tutorial provides insights into adjusting user operation gas values by a specified percentage.

:::caution
Exercise caution when implementing this approach. It is recommended to use this only for urgent situations where gas estimates fall short for specific operations.
:::

For instance, if gas estimates for verificationGasLimitOffsetPct and preVerificationGasOffsetPct are inaccurately low, this method allows for increasing these values by a defined percentage.

```typescript
const encodedCall = encodeFunctionData({
abi: parseAbi(["function safeMint(address _to)"]),
functionName: "safeMint",
args: [recipient]
})
const transaction = {
to: nftAddress,
data: encodedCall
}
const { wait } = await smartAccount.sendTransaction(transaction, {
gasOffset: {
verificationGasLimitOffsetPct: 25, // 25% increase
preVerificationGasOffsetPct: 9.80, // 9.80% increase
}
})
const {
receipt: { transactionHash },
userOpHash,
success
} = await wait()
```