Thirdweb 0.2.0
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Standard 2.1
This package targets .NET Standard 2.1. The package is compatible with this framework or higher.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Thirdweb --version 0.2.0
NuGet\Install-Package Thirdweb -Version 0.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Thirdweb" Version="0.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Thirdweb --version 0.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Thirdweb, 0.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Thirdweb as a Cake Addin #addin nuget:?package=Thirdweb&version=0.2.0 // Install Thirdweb as a Cake Tool #tool nuget:?package=Thirdweb&version=0.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Thirdweb .NET SDK
Overview
The Thirdweb .NET SDK is a powerful library that allows developers to interact with the blockchain using the .NET framework. It provides a set of convenient methods and classes to simplify the integration of Web3 functionality into your .NET applications.
Features
- Connect to any EVM network
- Query blockchain data using Thirdweb RPC
- Interact with smart contracts
- In-App Wallets
- Account Abstraction
- Compatible with GoDot
Installation
To use the Thirdweb .NET SDK in your project, you can either download the source code and build it manually, or install it via NuGet package manager.
dotnet add package Thirdweb
Usage
Simple Example
// A single client fits most use cases
var client = ThirdwebClient.Create(clientId: "myClientId", bundleId: "com.my.bundleid");
// Optionally pass abi, if not passed we fetch it for you
var contract = await ThirdwebContract.Create(client: client, address: "0x81ebd23aA79bCcF5AaFb9c9c5B0Db4223c39102e", chain: 421614);
var readResult = await ThirdwebContract.Read<string>(contract, "name");
Console.WriteLine($"Contract read result: {readResult}");
// Create InAppWallet wallet as signer to unlock web2 auth
var inAppWallet = await InAppWallet.Create(client: client, email: "email@email.com"); // or email: null, phoneNumber: "+1234567890"
// Relog if InAppWallet wallet not logged in
if (!await inAppWallet.IsConnected())
{
await inAppWallet.SendOTP();
Console.WriteLine("Please submit the OTP.");
var otp = Console.ReadLine();
(var inAppWalletAddress, var canRetry) = await inAppWallet.SubmitOTP(otp);
if (inAppWalletAddress == null && canRetry)
{
Console.WriteLine("Please submit the OTP again.");
otp = Console.ReadLine();
(inAppWalletAddress, _) = await inAppWallet.SubmitOTP(otp);
}
if (inAppWalletAddress == null)
{
Console.WriteLine("OTP login failed. Please try again.");
return;
}
}
// Create a smart wallet to unlock gasless features, with InAppWallet as a signer
var smartWallet = await SmartWallet.Create(client: client, personalWallet: inAppWallet, factoryAddress: "0xbf1C9aA4B1A085f7DA890a44E82B0A1289A40052", gasless: true, chainId: 421614);
// Log addresses
Console.WriteLine($"InAppWallet: {await inAppWallet.GetAddress()}");
Console.WriteLine($"Smart Wallet: {await smartWallet.GetAddress()}");
// Sign, triggering deploy as needed and 1271 verification if it's a smart wallet
var message = "Hello, Thirdweb!";
var signature = await smartWallet.PersonalSign(message);
Console.WriteLine($"Signed message: {signature}");
var writeResult = await ThirdwebContract.Write(smartWallet, contract, "mintTo", 0, await smartWallet.GetAddress(), 100);
Console.WriteLine($"Contract write result: {writeResult}");
Advanced Example
using Thirdweb;
// Do not use secret keys client side, use client id/bundle id instead
var secretKey = Environment.GetEnvironmentVariable("THIRDWEB_SECRET_KEY");
// Do not use private keys client side, use InAppWallet/SmartWallet instead
var privateKey = Environment.GetEnvironmentVariable("PRIVATE_KEY");
// Fetch timeout options are optional, default is 60000ms
var client = ThirdwebClient.Create(secretKey: secretKey, fetchTimeoutOptions: new TimeoutOptions(storage: 30000, rpc: 60000));
var contract = await ThirdwebContract.Create(client: client, address: "0x81ebd23aA79bCcF5AaFb9c9c5B0Db4223c39102e", chain: 421614);
var readResult = await ThirdwebContract.Read<string>(contract, "name");
Console.WriteLine($"Contract read result: {readResult}");
// Create wallets (this is an advanced use case, typically one wallet is plenty)
var privateKeyWallet = await PrivateKeyWallet.Create(client: client, privateKeyHex: privateKey);
var inAppWallet = await InAppWallet.Create(client: client, email: "email@email.com"); // or email: null, phoneNumber: "+1234567890"
// // Reset InAppWallet (optional step for testing login flow)
// if (await inAppWallet.IsConnected())
// {
// await inAppWallet.Disconnect();
// }
// Relog if InAppWallet not logged in
if (!await inAppWallet.IsConnected())
{
await inAppWallet.SendOTP();
Console.WriteLine("Please submit the OTP.");
var otp = Console.ReadLine();
(var inAppWalletAddress, var canRetry) = await inAppWallet.SubmitOTP(otp);
if (inAppWalletAddress == null && canRetry)
{
Console.WriteLine("Please submit the OTP again.");
otp = Console.ReadLine();
(inAppWalletAddress, _) = await inAppWallet.SubmitOTP(otp);
}
if (inAppWalletAddress == null)
{
Console.WriteLine("OTP login failed. Please try again.");
return;
}
}
// Create smart wallet with InAppWallet signer
var smartWallet = await SmartWallet.Create(client: client, personalWallet: inAppWallet, factoryAddress: "0xbf1C9aA4B1A085f7DA890a44E82B0A1289A40052", gasless: true, chainId: 421614);
// Connect the smart wallet with InAppWallet signer and grant a session key to pk wallet (advanced use case)
_ = await smartWallet.CreateSessionKey(
signerAddress: await privateKeyWallet.GetAddress(),
approvedTargets: new List<string>() { Constants.ADDRESS_ZERO },
nativeTokenLimitPerTransactionInWei: "0",
permissionStartTimestamp: "0",
permissionEndTimestamp: (Utils.GetUnixTimeStampNow() + 86400).ToString(),
reqValidityStartTimestamp: "0",
reqValidityEndTimestamp: Utils.GetUnixTimeStampIn10Years().ToString()
);
// Reconnect to same smart wallet with pk wallet as signer (specifying wallet address override)
smartWallet = await SmartWallet.Create(
client: client,
personalWallet: privateKeyWallet,
factoryAddress: "0xbf1C9aA4B1A085f7DA890a44E82B0A1289A40052",
gasless: true,
chainId: 421614,
accountAddressOverride: await smartWallet.GetAddress()
);
// Log addresses
Console.WriteLine($"PrivateKey Wallet: {await privateKeyWallet.GetAddress()}");
Console.WriteLine($"InAppWallet: {await inAppWallet.GetAddress()}");
Console.WriteLine($"Smart Wallet: {await smartWallet.GetAddress()}");
// Sign, triggering deploy as needed and 1271 verification if it's a smart wallet
var message = "Hello, Thirdweb!";
var signature = await smartWallet.PersonalSign(message);
Console.WriteLine($"Signed message: {signature}");
var balanceBefore = await ThirdwebContract.Read<BigInteger>(contract, "balanceOf", await smartWallet.GetAddress());
Console.WriteLine($"Balance before mint: {balanceBefore}");
var writeResult = await ThirdwebContract.Write(smartWallet, contract, "mintTo", 0, await smartWallet.GetAddress(), 100);
Console.WriteLine($"Contract write result: {writeResult}");
var balanceAfter = await ThirdwebContract.Read<BigInteger>(contract, "balanceOf", await smartWallet.GetAddress());
Console.WriteLine($"Balance after mint: {balanceAfter}");
// Storage actions
// // Will download from IPFS or normal urls
// var downloadResult = await ThirdwebStorage.Download<string>(client: client, uri: "AnyUrlIncludingIpfs");
// Console.WriteLine($"Download result: {downloadResult}");
// // Will upload to IPFS
// var uploadResult = await ThirdwebStorage.Upload(client: client, path: "AnyPath");
// Console.WriteLine($"Upload result preview: {uploadResult.PreviewUrl}");
// Access RPC directly if needed, generally not recommended
// var rpc = ThirdwebRPC.GetRpcInstance(client, 421614);
// var blockNumber = await rpc.SendRequestAsync<string>("eth_blockNumber");
// Console.WriteLine($"Block number: {blockNumber}");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- Amazon.Extensions.CognitoAuthentication (>= 2.5.0)
- AWSSDK.Lambda (>= 3.7.113.2)
- Nethereum.ABI (>= 4.19.0)
- Nethereum.Contracts (>= 4.19.0)
- Nethereum.HdWallet (>= 4.14.0)
- Nethereum.Hex (>= 4.19.0)
- Nethereum.Signer (>= 4.19.0)
- Nethereum.Signer.EIP712 (>= 4.19.0)
- Newtonsoft.Json (>= 13.0.3)
- Portable.BouncyCastle (>= 1.9.0)
-
net6.0
- Amazon.Extensions.CognitoAuthentication (>= 2.5.0)
- AWSSDK.Lambda (>= 3.7.113.2)
- Nethereum.ABI (>= 4.19.0)
- Nethereum.Contracts (>= 4.19.0)
- Nethereum.HdWallet (>= 4.14.0)
- Nethereum.Hex (>= 4.19.0)
- Nethereum.Signer (>= 4.19.0)
- Nethereum.Signer.EIP712 (>= 4.19.0)
- Newtonsoft.Json (>= 13.0.3)
- Portable.BouncyCastle (>= 1.9.0)
-
net7.0
- Amazon.Extensions.CognitoAuthentication (>= 2.5.0)
- AWSSDK.Lambda (>= 3.7.113.2)
- Nethereum.ABI (>= 4.19.0)
- Nethereum.Contracts (>= 4.19.0)
- Nethereum.HdWallet (>= 4.14.0)
- Nethereum.Hex (>= 4.19.0)
- Nethereum.Signer (>= 4.19.0)
- Nethereum.Signer.EIP712 (>= 4.19.0)
- Newtonsoft.Json (>= 13.0.3)
- Portable.BouncyCastle (>= 1.9.0)
-
net8.0
- Amazon.Extensions.CognitoAuthentication (>= 2.5.0)
- AWSSDK.Lambda (>= 3.7.113.2)
- Nethereum.ABI (>= 4.19.0)
- Nethereum.Contracts (>= 4.19.0)
- Nethereum.HdWallet (>= 4.14.0)
- Nethereum.Hex (>= 4.19.0)
- Nethereum.Signer (>= 4.19.0)
- Nethereum.Signer.EIP712 (>= 4.19.0)
- Newtonsoft.Json (>= 13.0.3)
- Portable.BouncyCastle (>= 1.9.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.9.0 | 72 | 11/15/2024 |
2.8.3 | 69 | 11/12/2024 |
2.8.2 | 75 | 11/8/2024 |
2.8.1 | 70 | 11/7/2024 |
2.7.1 | 66 | 11/7/2024 |
2.7.0 | 67 | 11/6/2024 |
2.6.1 | 90 | 10/24/2024 |
2.6.0 | 83 | 10/24/2024 |
2.5.2 | 78 | 10/24/2024 |
2.5.1 | 99 | 10/10/2024 |
2.5.0 | 82 | 10/9/2024 |
2.4.0 | 94 | 10/3/2024 |
2.3.1 | 90 | 10/2/2024 |
2.3.0 | 96 | 9/27/2024 |
2.2.2 | 105 | 9/23/2024 |
2.2.1 | 79 | 9/21/2024 |
2.2.0 | 85 | 9/20/2024 |
2.1.1 | 96 | 9/13/2024 |
2.1.0 | 122 | 9/11/2024 |
2.0.2 | 103 | 9/10/2024 |
2.0.1 | 106 | 9/9/2024 |
2.0.0 | 117 | 9/5/2024 |
1.5.0 | 125 | 8/20/2024 |
1.4.0 | 901 | 8/12/2024 |
1.3.0 | 94 | 8/7/2024 |
1.2.0 | 92 | 8/7/2024 |
1.1.0 | 81 | 8/2/2024 |
1.0.2 | 81 | 7/31/2024 |
1.0.1 | 97 | 7/16/2024 |
1.0.0 | 141 | 7/1/2024 |
0.4.0 | 147 | 6/1/2024 |
0.3.1 | 119 | 5/29/2024 |
0.3.0 | 121 | 5/23/2024 |
0.2.0 | 145 | 5/15/2024 |
0.1.1 | 150 | 4/15/2024 |
0.1.0 | 106 | 4/12/2024 |
0.0.13 | 103 | 4/10/2024 |
0.0.12 | 105 | 4/10/2024 |
0.0.11 | 96 | 4/10/2024 |
0.0.10 | 109 | 4/10/2024 |
0.0.9 | 118 | 4/10/2024 |
0.0.8 | 112 | 4/9/2024 |
0.0.7 | 101 | 4/9/2024 |
0.0.6 | 118 | 4/8/2024 |
0.0.5 | 119 | 4/5/2024 |
0.0.4 | 110 | 4/3/2024 |
0.0.3 | 101 | 4/3/2024 |
0.0.1 | 135 | 3/26/2024 |
0.0.0 | 134 | 3/26/2024 |