Skip to content

Commit 7293dfa

Browse files
committed
[Docs] .NET 2.10.0+ (#5842)
Closes TOOL-2440 <!-- start pr-codex --> --- ## PR-Codex overview This PR primarily focuses on refactoring the code to streamline interactions with contracts by removing references to `ThirdwebContract` and directly using `contract`. Additionally, it introduces new functionalities for unlinking accounts and enhances documentation across various pages. ### Detailed summary - Refactored contract interactions to use `contract` instead of `ThirdwebContract`. - Added `PurchaseData` object in `getbuywithfiatstatus` and `getbuywithfiatquote`. - Introduced unlinking functionality in in-app and ecosystem wallets. - Updated documentation for `SwitchNetwork` and `SignAuthorization`. - Improved descriptions and metadata for various pages. - Enhanced code examples and clarified usage instructions. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent e9c23ad commit 7293dfa

File tree

22 files changed

+233
-27
lines changed

22 files changed

+233
-27
lines changed

apps/portal/src/app/dotnet/contracts/extensions/page.mdx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,32 @@ Thirdweb's .NET SDK provides a set of useful type-safe extensions for calling sm
1212
## Usage
1313

1414
```csharp
15-
// Without extensions
15+
// Write without extensions
1616
var receiver = await wallet.GetAddress();
1717
var quantity = BigInteger.One;
1818
var currency = Constants.NATIVE_TOKEN_ADDRESS;
1919
var pricePerToken = BigInteger.Zero;
2020
var allowlistProof = new object[] { new byte[] { }, BigInteger.Zero, BigInteger.Zero, Constants.ADDRESS_ZERO };
2121
var data = new byte[] { };
22-
var receipt = await ThirdwebContract.Write(smartAccount, contract, "claim", 0, receiver, quantity, currency, pricePerToken, allowlistProof, data);
22+
var receipt = await contract.Write(smartAccount, contract, "claim", 0, receiver, quantity, currency, pricePerToken, allowlistProof, data);
2323

24-
// With extensions
24+
// Write with extensions
2525
var receipt = await contract.DropERC20_Claim(wallet, receiver, amount);
2626

27-
// Can also do read operations and much more
27+
// Read without extensions
28+
var balance = await contract.Read<string>("balanceOf", "0xOwnerAddress");
29+
30+
// Read with extensions
2831
var balance = await contract.ERC20_BalanceOf("0xOwnerAddress");
32+
33+
// Generate low level calldata
34+
var calldata = contract.CreateCallData("myFunction", param1, param2);
2935
```
3036

3137
## Available Contract Extensions
3238

3339
Please refer to the `ThirdwebExtensions` [full reference](https://thirdweb-dev.github.io/dotnet/docs/Thirdweb.ThirdwebExtensions.html) for a complete list of available contract extensions.
3440

41+
If you are using our [Marketplace](https://thirdweb.com/thirdweb.eth/MarketplaceV3) contract, check out our [Marketplace-specific](https://thirdweb-dev.github.io/dotnet/docs/Thirdweb.ThirdwebMarketplaceExtensions.html) extensions.
42+
3543

apps/portal/src/app/dotnet/contracts/prepare/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Useful for preparing, simulating and manipulating transactions before sending th
1515
## Usage
1616

1717
```csharp
18-
ThirdwebTransaction transaction = await ThirdwebContract.Prepare(wallet, contract, "methodName", weiValue, parameters);
18+
ThirdwebTransaction transaction = await contract.Prepare(wallet, contract, "methodName", weiValue, parameters);
1919
```
2020

2121
<Details summary="Parameters">

apps/portal/src/app/dotnet/contracts/read/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Use `ThirdwebContract.Read` to fetch data from a smart contract without making a
1212
## Usage
1313

1414
```csharp
15-
var result = await ThirdwebContract.Read<T>(contract, "methodName", parameters);
15+
var result = await contract.Read<T>(contract, "methodName", parameters);
1616
```
1717

1818
<Details summary="Parameters">

apps/portal/src/app/dotnet/contracts/write/page.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The `ThirdwebContract.Write` method allows you to execute transactions that alte
1212
## Usage
1313

1414
```csharp
15-
var transactionReceipt = await ThirdwebContract.Write(wallet, contract, "methodName", weiValue, parameters);
15+
var transactionReceipt = await contract.Write(wallet, contract, "methodName", weiValue, parameters);
1616
```
1717

1818
<Details summary="Parameters">
@@ -68,7 +68,7 @@ BigInteger amount = new BigInteger(1000); // The amount to transfer
6868
BigInteger weiValue = BigInteger.Zero;
6969

7070
// Executing the transfer
71-
var receipt = await ThirdwebContract.Write(wallet, contract, "transfer", weiValue, toAddress, amount);
71+
var receipt = await contract.Write(wallet, contract, "transfer", weiValue, toAddress, amount);
7272
Console.WriteLine($"Transaction receipt: {receipt}");
7373
```
7474

apps/portal/src/app/dotnet/getting-started/page.mdx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,17 @@ This command adds the Thirdweb SDK to your project, allowing you to interact wit
3939
Create a new instance of the Thirdweb client in your application:
4040

4141
```csharp
42-
// For Frontend Applications
42+
// For Web Applications
43+
var client = ThirdwebClient.Create(clientId: "yourClientId");
44+
45+
// For Native Applications
4346
var client = ThirdwebClient.Create(clientId: "yourClientId", bundleId: "yourBundleId");
4447

4548
// For Backend Applications
4649
var client = ThirdwebClient.Create(secretKey: "yourSecretKey");
4750
```
4851

49-
Replace "yourClientId" and "yourBundleId" with your actual client ID and bundle ID. Note that a bundle ID is only required if you are not using the SDK from a web application.
52+
Replace "yourClientId" and "yourBundleId" with your actual client ID and bundle ID.
5053

5154
</Step>
5255
<Step title="Interact with Smart Contracts" >
@@ -55,7 +58,7 @@ Now, you can start interacting with smart contracts. For example, to read from a
5558

5659
```csharp
5760
var contract = await ThirdwebContract.Create(client: client, address: "contractAddress", chain: chainId);
58-
var readResult = await ThirdwebContract.Read<string>(contract, "methodName");
61+
var readResult = await contract.Read<string>(contract, "methodName");
5962
Console.WriteLine($"Contract read result: {readResult}");
6063
```
6164

apps/portal/src/app/dotnet/page.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { GraduationCap } from "lucide-react";
33

44
# .NET SDK
55

6-
A .NET SDK to integrate blockchain and web3 capabilities into your applications.
6+
Build decentralized .NET applications and create seamless user experiences using Thirdweb's .NET SDK.
77

88
Connect to users’ wallets, interact with smart contracts, sign messages, and utilize common standards such as tokens, NFTs, and marketplaces; all with built-in RPC URLs, IPFS gateways, and more.
99

1010
<OpenSourceCard
1111
title=".NET SDK"
12-
href="https://github.com/thirdweb-dev/thirdweb-dotnet"
12+
href="https://github.com/thirdweb-dev/dotnet"
1313
isLibrary={true}
1414
/>
1515

apps/portal/src/app/dotnet/pay/getbuywithcryptoquote/page.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ string toAmountWei; // Optional, amount of to token in wei
4949
string toAddress; // Optional, address to receive the to token
5050
int? maxSlippageBPS; // Optional, maximum slippage in basis points
5151
string intentId; // Optional, intent identifier used to link status to a BuyWithFiat onramp flow if any
52+
object purchaseData; // Optional, additional data to be passed and retained during the flow
5253
```
5354

5455
</Details>

apps/portal/src/app/dotnet/pay/getbuywithcryptostatus/page.mdx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@ var status = await ThirdwebPay.GetBuyWithCryptoStatus(client, txHash);
3636
A `BuyWithCryptoStatusResult` object containing the following properties:
3737

3838
```csharp
39-
Quote quote; // The quote object containing the swap details.
40-
string swapType; // The swap type, see SwapType enum.
41-
TransactionDetails source; // The source transaction details.
42-
TransactionDetails destination; // The destination transaction details.
43-
string status; // The status of the swap, see SwapStatus enum.
44-
string subStatus; // The sub status of the swap, see SwapSubStatus enum.
45-
string fromAddress; // The source address.
46-
string failureMessage; // The failure message if the swap failed.
47-
string bridge // The bridge used for the swap if applicable.
39+
Quote Quote; // The quote object containing the swap details.
40+
string SwapType; // The swap type, see SwapType enum.
41+
TransactionDetails Source; // The source transaction details.
42+
TransactionDetails Destination; // The destination transaction details.
43+
string Status; // The status of the swap, see SwapStatus enum.
44+
string SubStatus; // The sub status of the swap, see SwapSubStatus enum.
45+
string FromAddress; // The source address.
46+
string FailureMessage; // The failure message if the swap failed.
47+
string Bridge; // The bridge used for the swap if applicable.
48+
object PurchaseData; // Additional data passed when creating the quote
4849
```
4950

5051
</Details>

apps/portal/src/app/dotnet/pay/getbuywithfiatquote/page.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ string toAmount; // Optional, amount of to token
4949
string toAmountWei; // Optional, amount of to token in wei
5050
double? maxSlippageBPS; // Optional, maximum slippage in basis points
5151
bool isTestMode; // Optional, enters test mode onramp flow, defaults to false
52+
string preferredProvider; // Optional, can be set to "STRIPE", "KADO", etc.
53+
object purchaseData; // Optional, additional data to be passed and retained during the flow
5254
```
5355

5456
</Details>

apps/portal/src/app/dotnet/pay/getbuywithfiatstatus/page.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ OnRampQuote Quote; // OnRamp Quote details
4545
TransactionDetails Source; // Source transaction details
4646
TransactionDetails Destination; // Destination transaction details
4747
string FailureMessage; // Failure message if any
48+
object PurchaseData; // Additional data passed when creating the quote
4849
```
4950

5051
</Details>

apps/portal/src/app/dotnet/sidebar.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ const walletActions: SidebarLink = (() => {
7272
name: "Transfer",
7373
href: `${parentSlug}/transfer`,
7474
},
75+
{
76+
name: "SwitchNetwork",
77+
href: `${parentSlug}/switchnetwork`,
78+
},
79+
{
80+
name: "SignAuthorization (Experimental)",
81+
href: `${parentSlug}/signauthorization`,
82+
},
7583
],
7684
},
7785
{
@@ -82,6 +90,10 @@ const walletActions: SidebarLink = (() => {
8290
name: "GetUserDetails",
8391
href: `${parentSlug}/getuserdetails`,
8492
},
93+
{
94+
name: "GetUserAuthDetails",
95+
href: `${parentSlug}/getuserauthdetails`,
96+
},
8597
{
8698
name: "GetEcosystemDetails",
8799
href: `${parentSlug}/getecosystemdetails`,
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Details, createMetadata } from "@doc";
2+
3+
export const metadata = createMetadata({
4+
title: "EcosystemWallet.GetUserAuthDetails | Thirdweb .NET SDK",
5+
description: "Gets the user auth details from the corresponding auth provider.",
6+
});
7+
8+
# EcosystemWallet.GetUserDetails
9+
10+
This method returns information about the connected user auth provider details, for instance Google or Github specific details.
11+
12+
## Usage
13+
14+
```csharp
15+
var result = ecosystemWallet.GetUserAuthDetails();
16+
```
17+
18+
<Details summary="Return Value">
19+
20+
### JObject
21+
22+
The user auth provider details as a `JObject`.
23+
24+
</Details>

apps/portal/src/app/dotnet/wallets/actions/sign/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const metadata = createMetadata({
99

1010
This method allows signing a string message using the wallet's private key. The signed message proves the message's integrity and authenticity, demonstrating that the message was indeed created by the owner of the private key.
1111

12-
**Note:** When using `SmartWallet`, calling this method will deploy a smart contract account if it hasn't been deployed yet.
12+
**Note:** When using `SmartWallet`, calling this method from an undeployed smart account will make use of [EIP-6492](https://eips.ethereum.org/EIPS/eip-6492).
1313

1414
## Usage
1515

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import { Details, createMetadata } from "@doc";
2+
3+
export const metadata = createMetadata({
4+
title: "IThirdwebWallet.SignAuthorization | Thirdweb .NET SDK",
5+
description: "Sign an EIP-7702 Payload to Set Code to your EOA.",
6+
});
7+
8+
# [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) Integration (Experimental)
9+
Integrates `authorizationList` for any transactions.
10+
This EIP essentially allows you to set code to an EOA, unlocking a world of possibilities to enhance their functionality.
11+
12+
The best way to understand it outside of reading the EIP is looking at the example below; to preface it: we sign an authorization using the wallet we want to set code to. Another wallet sends a transaction with said authorization passed in, essentially activating it. The authority wallet now has code set to it pointing to an (insecure) [Delegation](https://thirdweb.com/odyssey-911867/0x654F42b74885EE6803F403f077bc0409f1066c58) contract in this case, which allows any wallet to execute any call through it on behalf of the authority. In this example, we call the wallet executing both the authorization and the claim transaction afterwards, the exectuor.
13+
14+
An authority may execute its own authorization, the only difference is internal whereby the authorization nonce is incremented by 1.
15+
16+
```csharp
17+
// Chain and contract addresses
18+
var chainWith7702 = 911867;
19+
var erc20ContractAddress = "0xAA462a5BE0fc5214507FDB4fB2474a7d5c69065b"; // Fake ERC20
20+
var delegationContractAddress = "0x654F42b74885EE6803F403f077bc0409f1066c58"; // BatchCallDelegation
21+
22+
// Initialize contracts normally
23+
var erc20Contract = await ThirdwebContract.Create(client: client, address: erc20ContractAddress, chain: chainWith7702);
24+
var delegationContract = await ThirdwebContract.Create(client: client, address: delegationContractAddress, chain: chainWith7702);
25+
26+
// Initialize a (to-be) 7702 EOA
27+
var eoaWallet = await PrivateKeyWallet.Generate(client);
28+
var eoaWalletAddress = await eoaWallet.GetAddress();
29+
Console.WriteLine($"EOA address: {eoaWalletAddress}");
30+
31+
// Initialize another wallet, the "executor" that will hit the eoa's (to-be) execute function
32+
var executorWallet = await PrivateKeyWallet.Generate(client);
33+
var executorWalletAddress = await executorWallet.GetAddress();
34+
Console.WriteLine($"Executor address: {executorWalletAddress}");
35+
36+
// Fund the executor wallet
37+
var fundingWallet = await PrivateKeyWallet.Create(client, privateKey);
38+
var fundingHash = (await fundingWallet.Transfer(chainWith7702, executorWalletAddress, BigInteger.Parse("0.001".ToWei()))).TransactionHash;
39+
Console.WriteLine($"Funded Executor Wallet: {fundingHash}");
40+
41+
// Sign the authorization to make it point to the delegation contract
42+
var authorization = await eoaWallet.SignAuthorization(chainId: chainWith7702, contractAddress: delegationContractAddress, willSelfExecute: false);
43+
Console.WriteLine($"Authorization: {JsonConvert.SerializeObject(authorization, Formatting.Indented)}");
44+
45+
// Execute the delegation
46+
var tx = await ThirdwebTransaction.Create(executorWallet, new ThirdwebTransactionInput(chainId: chainWith7702, to: executorWalletAddress, authorization: authorization));
47+
var hash = (await ThirdwebTransaction.SendAndWaitForTransactionReceipt(tx)).TransactionHash;
48+
Console.WriteLine($"Authorization execution transaction hash: {hash}");
49+
50+
// Prove that code has been deployed to the eoa
51+
var rpc = ThirdwebRPC.GetRpcInstance(client, chainWith7702);
52+
var code = await rpc.SendRequestAsync<string>("eth_getCode", eoaWalletAddress, "latest");
53+
Console.WriteLine($"EOA code: {code}");
54+
55+
// Log erc20 balance of executor before the claim
56+
var executorBalanceBefore = await erc20Contract.ERC20_BalanceOf(executorWalletAddress);
57+
Console.WriteLine($"Executor balance before: {executorBalanceBefore}");
58+
59+
// Prepare the claim call
60+
var claimCallData = erc20Contract.CreateCallData(
61+
"claim",
62+
new object[]
63+
{
64+
executorWalletAddress, // receiver
65+
100, // quantity
66+
Constants.NATIVE_TOKEN_ADDRESS, // currency
67+
0, // pricePerToken
68+
new object[] { Array.Empty<byte>(), BigInteger.Zero, BigInteger.Zero, Constants.ADDRESS_ZERO }, // allowlistProof
69+
Array.Empty<byte>() // data
70+
}
71+
);
72+
73+
// Embed the claim call in the execute call
74+
var executeCallData = delegationContract.CreateCallData(
75+
method: "execute",
76+
parameters: new object[]
77+
{
78+
new List<Thirdweb.Console.Call>
79+
{
80+
new()
81+
{
82+
Data = claimCallData.HexToBytes(),
83+
To = erc20ContractAddress,
84+
Value = BigInteger.Zero
85+
}
86+
}
87+
}
88+
);
89+
90+
// Execute from the executor wallet targeting the eoa which is pointing to the delegation contract
91+
var tx2 = await ThirdwebTransaction.Create(executorWallet, new ThirdwebTransactionInput(chainId: chainWith7702, to: eoaWalletAddress, data: executeCallData));
92+
var hash2 = (await ThirdwebTransaction.SendAndWaitForTransactionReceipt(tx2)).TransactionHash;
93+
Console.WriteLine($"Token claim transaction hash: {hash2}");
94+
95+
// Log erc20 balance of executor after the claim
96+
var executorBalanceAfter = await erc20Contract.ERC20_BalanceOf(executorWalletAddress);
97+
Console.WriteLine($"Executor balance after: {executorBalanceAfter}");
98+
```
99+
100+
_Note that for the time being this only works on 7702-enabled chains such as [Odyssey](https://thirdweb.com/odyssey-911867) and the feature has only been integrated with `PrivateKeyWallet`._
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Details, createMetadata } from "@doc";
2+
3+
export const metadata = createMetadata({
4+
title: "IThirdwebWallet.SwitchNetwork | Thirdweb .NET SDK",
5+
description: "Enables setting the active chain of the wallet if applicable.",
6+
});
7+
8+
# IThirdwebWallet.SwitchNetwork
9+
10+
This method allows setting the active chain of the wallet if applicable.
11+
12+
When using Smart Wallets, make sure any overrides to default contracts, such as factories, are deployed on all chains you intend to switch to. We also support switching between zksync and non-zksync chains.
13+
14+
## Usage
15+
16+
```csharp
17+
await wallet.SwitchNetwork(chainId);
18+
```
19+
20+
<Details summary="Parameters">
21+
22+
### chainId (required)
23+
24+
The chain ID to which you want to switch the wallet.
25+
26+
</Details>

apps/portal/src/app/dotnet/wallets/providers/ecosystem-wallet/page.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,3 +287,10 @@ _ = await ecosystemWalletMain.LinkAccount(walletToLink: phoneWallet, otp: otp);
287287
```csharp
288288
List<LinkedAccount> linkedAccounts = await ecosystemWalletMain.GetLinkedAccounts();
289289
```
290+
291+
### Unlinking Accounts
292+
293+
```csharp
294+
List<LinkedAccount> linkedAccounts = await ecosystemWallet.GetLinkedAccounts();
295+
List<LinkedAccount> linkedAccountsAfterUnlinking = await ecosystemWallet.UnlinkAccount(linkedAccounts[0]);
296+
```

apps/portal/src/app/dotnet/wallets/providers/in-app-wallet/page.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,3 +292,10 @@ _ = await inAppWalletMain.LinkAccount(walletToLink: phoneWallet, otp: otp);
292292
```csharp
293293
List<LinkedAccount> linkedAccounts = await inAppWalletMain.GetLinkedAccounts();
294294
```
295+
296+
### Unlinking Accounts
297+
298+
```csharp
299+
List<LinkedAccount> linkedAccounts = await inAppWallet.GetLinkedAccounts();
300+
List<LinkedAccount> linkedAccountsAfterUnlinking = await inAppWallet.UnlinkAccount(linkedAccounts[0]);
301+
```

apps/portal/src/app/unity/v5/build-instructions/page.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const metadata = createMetadata({
1313
- **Build Settings:** Use `Smaller (faster) Builds` / `Shorter Build Time`.
1414
- **Player Settings:** Use IL2CPP over Mono when available.
1515
- **Stripping Level:** Set `Managed Stripping Level` to `Minimal` (`Player Settings` > `Other Settings` > `Optimization`). (Generally not a hard requirement unless using WalletConnect as a wallet provider option.)
16+
- **Strip Engine Code:** Make sure this is turned off.
1617

1718
## WebGL
1819

@@ -47,3 +48,8 @@ No action needed for hosted builds.
4748

4849
- **EDM4U:** Comes with the package, resolves dependencies at runtime. Use `Force Resolve` from `Assets` > `External Dependency Manager` > `Android Resolver`.
4950
- **Redirect Schemes:** Set custom schemes matching your bundle ID in `Plugins/AndroidManifest.xml` or equivalent to ensure OAuth redirects.
51+
```xml
52+
<!-- Set your bundle id here -->
53+
<!-- Replace 'com.thirdweb.unitysdk' with your desired scheme -->
54+
<data android:scheme="com.thirdweb.unitysdk" />
55+
```

0 commit comments

Comments
 (0)