Thirdweb 0.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package Thirdweb --version 0.0.4
                    
NuGet\Install-Package Thirdweb -Version 0.0.4
                    
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.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Thirdweb" Version="0.0.4" />
                    
Directory.Packages.props
<PackageReference Include="Thirdweb" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Thirdweb --version 0.0.4
                    
#r "nuget: Thirdweb, 0.0.4"
                    
#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.
#addin nuget:?package=Thirdweb&version=0.0.4
                    
Install Thirdweb as a Cake Addin
#tool nuget:?package=Thirdweb&version=0.0.4
                    
Install Thirdweb as a Cake Tool

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

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

using Thirdweb;

// Create a client
var client = new ThirdwebClient(secretKey: secretKey);

// Interact with a contract
var contract = new ThirdwebContract(client: client, address: "0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D", chain: 1, abi: "function name() view returns (string)");
var readResult = await ThirdwebContract.ReadContract<string>(contract, "name");
Console.WriteLine($"Contract read result: {readResult}");

// Or directly interact with the RPC
var rpc = ThirdwebRPC.GetRpcInstance(client, 1);
var blockNumber = await rpc.SendRequestAsync<string>("eth_blockNumber");
Console.WriteLine($"Block number: {blockNumber}");

// Create accounts
var privateKeyAccount = new PrivateKeyAccount(client, privateKey);
var embeddedAccount = new EmbeddedAccount(client, "myawesomeemail@gmail.com");
var smartAccount = new SmartAccount(client, embeddedAccount, "0xbf1C9aA4B1A085f7DA890a44E82B0A1289A40052", true, 421614);

// Attempt to connect pk accounts
await privateKeyAccount.Connect();
await embeddedAccount.Connect();

// Relog if embedded account not logged in
if (!await embeddedAccount.IsConnected())
{
    await embeddedAccount.SendOTP();
    Console.WriteLine("Please submit the OTP.");
    var otp = Console.ReadLine();
    (var embeddedAccountAddress, var canRetry) = await embeddedAccount.SubmitOTP(otp);
    if (embeddedAccountAddress == null && canRetry)
    {
        Console.WriteLine("Please submit the OTP again.");
        otp = Console.ReadLine();
        (embeddedAccountAddress, _) = await embeddedAccount.SubmitOTP(otp);
    }
    if (embeddedAccountAddress == null)
    {
        Console.WriteLine("OTP login failed. Please try again.");
        return;
    }
}

// Connect the smart account with embedded signer and grant a session key to pk account
await smartAccount.Connect();
_ = await smartAccount.CreateSessionKey(
    signerAddress: await privateKeyAccount.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 account with pk account as signer
smartAccount = new SmartAccount(client, privateKeyAccount, "0xbf1C9aA4B1A085f7DA890a44E82B0A1289A40052", true, 421614, await smartAccount.GetAddress());
await smartAccount.Connect();

// Log addresses
Console.WriteLine($"PrivateKey Account: {await privateKeyAccount.GetAddress()}");
Console.WriteLine($"Embedded Account: {await embeddedAccount.GetAddress()}");
Console.WriteLine($"Smart Account: {await smartAccount.GetAddress()}");

// Initialize wallet
var thirdwebWallet = new ThirdwebWallet();
await thirdwebWallet.Initialize(new List<IThirdwebAccount> { privateKeyAccount, embeddedAccount, smartAccount });
thirdwebWallet.SetActive(await smartAccount.GetAddress());
Console.WriteLine($"Active account: {await thirdwebWallet.GetAddress()}");

// Sign, triggering deploy as needed and 1271 verification
var message = "Hello, Thirdweb!";
var signature = await thirdwebWallet.PersonalSign(message);
Console.WriteLine($"Signed message: {signature}");
Product 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 was computed.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.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.

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.19.1 156 4/21/2025
2.19.0 86 3/21/2025
2.18.6 140 3/19/2025
2.18.5 139 3/13/2025
2.18.4 143 3/12/2025
2.18.3 150 3/12/2025
2.18.2 223 2/28/2025
2.18.1 105 2/21/2025
2.18.0 93 2/21/2025
2.17.2 149 2/13/2025
2.17.1 102 2/7/2025
2.17.0 87 1/24/2025
2.16.0 92 1/17/2025
2.15.0 104 1/10/2025
2.14.0 94 1/10/2025
2.13.0 97 1/6/2025
2.12.1 111 12/26/2024
2.12.0 109 12/25/2024
2.11.1 122 12/9/2024
2.11.0 102 12/6/2024
2.10.1 136 11/27/2024
2.10.0 125 11/22/2024
2.9.0 104 11/15/2024
2.8.3 106 11/12/2024
2.8.2 104 11/8/2024
2.8.1 101 11/7/2024
2.7.1 115 11/7/2024
2.7.0 98 11/6/2024
2.6.1 112 10/24/2024
2.6.0 103 10/24/2024
2.5.2 98 10/24/2024
2.5.1 125 10/10/2024
2.5.0 106 10/9/2024
2.4.0 123 10/3/2024
2.3.1 107 10/2/2024
2.3.0 112 9/27/2024
2.2.2 130 9/23/2024
2.2.1 98 9/21/2024
2.2.0 104 9/20/2024
2.1.1 110 9/13/2024
2.1.0 136 9/11/2024
2.0.2 118 9/10/2024
2.0.1 119 9/9/2024
2.0.0 133 9/5/2024
1.5.0 141 8/20/2024
1.4.0 2,023 8/12/2024
1.3.0 111 8/7/2024
1.2.0 109 8/7/2024
1.1.0 99 8/2/2024
1.0.2 97 7/31/2024
1.0.1 118 7/16/2024
1.0.0 160 7/1/2024
0.4.0 159 6/1/2024
0.3.1 132 5/29/2024
0.3.0 136 5/23/2024
0.2.0 160 5/15/2024
0.1.1 164 4/15/2024
0.1.0 117 4/12/2024
0.0.13 116 4/10/2024
0.0.12 117 4/10/2024
0.0.11 109 4/10/2024
0.0.10 121 4/10/2024
0.0.9 130 4/10/2024
0.0.8 125 4/9/2024
0.0.7 112 4/9/2024
0.0.6 133 4/8/2024
0.0.5 131 4/5/2024
0.0.4 122 4/3/2024
0.0.3 113 4/3/2024
0.0.1 145 3/26/2024
0.0.0 146 3/26/2024