Net.Web3.EthereumWallet.Json 1.2.0

dotnet add package Net.Web3.EthereumWallet.Json --version 1.2.0                
NuGet\Install-Package Net.Web3.EthereumWallet.Json -Version 1.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="Net.Web3.EthereumWallet.Json" Version="1.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Net.Web3.EthereumWallet.Json --version 1.2.0                
#r "nuget: Net.Web3.EthereumWallet.Json, 1.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 Net.Web3.EthereumWallet.Json as a Cake Addin
#addin nuget:?package=Net.Web3.EthereumWallet.Json&version=1.2.0

// Install Net.Web3.EthereumWallet.Json as a Cake Tool
#tool nuget:?package=Net.Web3.EthereumWallet.Json&version=1.2.0                

Net.Web3.EthereumWallet.Json

Description

Net.Web3.EthereumWallet.Json is a C# library that adds a Newtonsoft.Json converter for the EthereumAddress class from the Net.Web3.EthereumWallet library.

Installation

You can install the package via NuGet:

Install-Package Net.Web3.EthereumWallet.Json

Or using .NET CLI:

dotnet add package Net.Web3.EthereumWallet.Json

Usage

To use the Net.Web3.EthereumWallet.Json converter, you need to configure Newtonsoft.Json to recognize and handle the EthereumAddress type. Below are examples demonstrating how to serialize and deserialize objects containing EthereumAddress properties.

Example Scenario

Suppose you have a User class that includes an EthereumAddress property:

using Newtonsoft.Json;
using Net.Web3.EthereumWallet;

public class User
{
    public string Name { get; set; }

    [JsonConverter(typeof(Net.Web3.EthereumWallet.Json.Converters.EthereumAddressConverter))]
    public EthereumAddress Address { get; set; }
}

Serialization

To serialize a User object to JSON, ensuring that the EthereumAddress is properly converted to a string:

using System;
using Newtonsoft.Json;
using Net.Web3.EthereumWallet;
using Net.Web3.EthereumWallet.Json.Converters;

public class Program
{
    public static void Main()
    {
        var user = new User
        {
            Name = "Alice",
            Address = "0x1234567890abcdef1234567890abcdef12345678"
        };

        string json = JsonConvert.SerializeObject(user, Formatting.Indented);
        Console.WriteLine(json);
    }
}
Output:
{
  "Name": "Alice",
  "Address": "0x1234567890abcdef1234567890abcdef12345678"
}

Deserialization

To deserialize JSON back into a User object, ensuring that the Address string is correctly converted to an EthereumAddress instance:

using System;
using Newtonsoft.Json;
using Net.Web3.EthereumWallet;
using Net.Web3.EthereumWallet.Json.Converters;

public class Program
{
    public static void Main()
    {
        var json = @"{
            ""Name"": ""Bob"",
            ""Address"": ""0xabcdefabcdefabcdefabcdefabcdefabcdefabcd""
        }";

        var user = JsonConvert.DeserializeObject<User>(json)!;

        Console.WriteLine($"Deserialized UserName: {user.Name}");
        Console.WriteLine($"Deserialized UserAddress: {user.Address.Address}");
    }
}
Output:
Deserialized User Name: Bob
Deserialized User Address: 0xabcdefabcdefabcdefabcdefabcdefabcdefabcd

License

Net.Web3.EthereumWallet.Json is open-sourced software licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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
1.2.0 20 1/8/2025