Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into mnn/changelog-redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
MananTank authored Jul 25, 2024
2 parents c4f9614 + 84707d9 commit 2dd916c
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 31 deletions.
85 changes: 54 additions & 31 deletions src/app/unity/contracts/prepare/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,24 @@ To gain more granular control over the transaction process, all Contract objects
string connectedAddress = await ThirdwebManager.Instance.SDK.Wallet.GetAddress();
Transaction transaction = await contract.Prepare(
functionName: "claim",
from: connectedAddress, // optional, defaults to connected address
args: new object[] { connectedAddress, 0, 1 }
);
// transaction.SetValue("0.00000000001");
// transaction.SetGasLimit("100000");

try
{
var data = await transaction.Simulate();
Debugger.Instance.Log("[Custom Call] Simulate Successful", $"Data: {data}");
}
catch (System.Exception e)
{
Debugger.Instance.Log("[Custom Call] Simulate Error", e.Message);
return;
}

await transaction.EstimateAndSetGasLimitAsync();
// This step is optional if you don't care about visualizing the input, tx.Send will do it for you
_ = await tx.Popuate();
Debug.Log($"Transaction input after preparing: {tx}");

var gasPrice = await transaction.GetGasPrice();
Debug.Log($"Gas Price: {gasPrice}");
// You may update the input if you want
var increasedGasLimit = tx.Input.Gas.Value * 10 / 9;
_ = tx.SetGasLimit(increasedGasLimit.ToString());

var gasCosts = await transaction.EstimateGasCosts();
Debug.Log($"Gas Cost: {gasCosts.wei} WEI");
// Send without waiting for the transaction to be mined
var hash = await tx.Send();
Debug.Log($"Transaction hash: {hash}");

Debugger.Instance.Log("[Custom Call] Transaction Preview", transaction.ToString());

try
{
string transactionResult = await transaction.Send();
Debugger.Instance.Log("[Custom Call] Send Successful", "Tx Hash: " + transactionResult);
}
catch (System.Exception e)
{
Debugger.Instance.Log("[Custom Call] Send Error", e.ToString());
}
// or you can wait for the transaction to be mined if you don't care about the hash
// var receipt = await tx.SendAndWaitForTransactionResult();
// Debug.Log($"Transaction receipt: {receipt}");
```

Please be advised that in most cases you do not need to use these functions, as the SDK will handle the transaction process for you. However, if you need more granular control over the transaction process, these functions can be used to fine-tune the transaction.
Expand Down Expand Up @@ -360,7 +342,7 @@ Returns the `Transaction` object.

### GetGasPrice

Get the gas price.
Get the gas price (for legacy transactions).

```csharp
var gasPrice = await tx.GetGasPrice();
Expand All @@ -374,6 +356,29 @@ Returns the gas price in wei as a `BigInteger`.

</Details>

### GetGasFees

Get the max fee per gas and max priority fee per gas (for EIP-1559 transactions).

```csharp
var gasFees = await tx.GetGasFees();
```

<Details summary="Configuration">

#### Return Value

Returns the gas fees as a `GasPriceParameters` object.

```csharp
{
BigInteger MaxFeePerGas;
BigInteger MaxPriorityFeePerGas;
}
```

</Details>

### EstimateGasLimit

Estimate the gas limit for the transaction.
Expand Down Expand Up @@ -467,6 +472,24 @@ Returns the signed transaction or hexified UserOperation as a `string`.

</Details>

### Populate

Populates the transaction with the necessary data to be sent. This is called automatically by the SDK when sending a transaction, but can be called manually if needed.

There is no guarantee the gas and nonce values will be preserved when using Account Abstraction.

```csharp
await tx.Populate();
```

<Details summary="Configuration">

#### Return Value

Returns the updated `Transaction` object.

</Details>

### Send

Sends the transaction without waiting for it to be mined. Returns a transaction hash instead of the typical transaction receipt object.
Expand Down
4 changes: 4 additions & 0 deletions src/app/unity/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ const walletActions: SidebarLink = (() => {
name: "GetEmail",
href: `${parentSlug}/getemail`,
},
{
name: "GetNonce",
href: `${parentSlug}/getnonce`,
},
{
name: "GetSignerAddress",
href: `${parentSlug}/getsigneraddress`,
Expand Down
34 changes: 34 additions & 0 deletions src/app/unity/wallets/actions/getnonce/page.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { createMetadata } from "@doc";

export const metadata = createMetadata({
title: "wallet.GetNonce | thirdweb Unity SDK",
description: "Get the none of the currently connected wallet",
});

# GetNonce

Get the nonce of the currently connected wallet. Defauts to pending blockTag.

## Usage

Call this method to get the nonce of the currently connected wallet.

```csharp
var nonce = await sdk.Wallet.GetNonce();
```

## Configuration

### blockTag (optional)

The block tag to get the nonce for. Must be a `string`.

If no block tag is provided, the default is `pending`.

```csharp
var nonce = await sdk.Wallet.GetNonce("latest");
```

## Return Value

Returns the nonce as an `int`.

0 comments on commit 2dd916c

Please sign in to comment.