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

Commit

Permalink
contract.write update and receipt polling static
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFirekeeper committed Apr 13, 2024
1 parent 9f15bab commit 8e4c2f2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/app/dotnet/contracts/write/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ The parameters to pass to the smart contract method, if any. Provide these as a
</Details>

<Details summary="Return Value">
### string

Returns the transaction hash as a `string`. This hash can be used to track the status of the transaction on the blockchain.
### TransactionReceipt

Returns the transaction receipt as a `TransactionReceipt` object, which contains information about the executed transaction.

</Details>

Expand All @@ -67,11 +68,8 @@ BigInteger amount = new BigInteger(1000); // The amount to transfer
BigInteger weiValue = BigInteger.Zero;

// Executing the transfer
var transactionHash = await ThirdwebContract.Write(wallet, contract, "transfer", weiValue, toAddress, amount);
Console.WriteLine($"Transaction hash: {transactionHash}");

// Poll for the receipt
var transactionReceipt = await Utils.GetTransactionReceipt(transactionHash);
var receipt = await ThirdwebContract.Write(wallet, contract, "transfer", weiValue, toAddress, amount);
Console.WriteLine($"Transaction receipt: {receipt}");
```

This method is essential for interacting with smart contracts when you need to make changes to the blockchain, such as updating state or transferring assets.
36 changes: 36 additions & 0 deletions src/app/dotnet/transactions/static/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,39 @@ An instance of `ThirdwebTransaction`. The transaction you are sending and waitin
Returns the transaction receipt as a `TransactionReceipt`, which includes details of the transaction execution result.

</Details>

## ThirdwebTransaction.WaitForTransactionReceipt

Wait for a transaction receipt to be available. Throws if reverted explicitly or silently and attempts to decode the revert reason.

```csharp
TransactionReceipt receipt = await ThirdwebTransaction.WaitForTransactionReceipt(client, chainId, txHash);
```

<Details summary="Parameters">

### client (required)

An instance of `ThirdwebClient`.

### chainId (required)

The chain ID of the blockchain network where the transaction was sent. Must be a `BigInteger`.

### txHash (required)

The hash of the transaction you are waiting for. Must be a hexadecimal `string`.

### cancellationToken (optional)

A `CancellationToken` to cancel the operation.

</Details>

<Details summary="Return Value">

### TransactionReceipt

Returns the transaction receipt as a `TransactionReceipt`, which includes details of the transaction execution result.

</Details>

0 comments on commit 8e4c2f2

Please sign in to comment.