MerkleTools-solidity 1.0.0

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

// Install MerkleTools-solidity as a Cake Tool
#tool nuget:?package=MerkleTools-solidity&version=1.0.0                

MerkleTools

MerkleTools-solidity is a .NET library to create and validate Merkle trees and receipts compatible with @openzeppelin/contracts/utils/cryptography/MerkleProof.sol using keccak256 hash algorithm.

Example

using MerkleTools;
using System.Text;

MerkleTree tree = new MerkleTree();

string[] addresses = {  "0xa18FBe02d2f247922a8e7A9B3962cfd3b8aEE0Ca", 
                        "0x5B38Da6a701c568545dCfcB03FcB875f56beddC4", 
                        "0x25f7fF7917555132eDD3294626D105eA1C797250", 
                        "0xF6574D878f99D94896Da75B6762fc935F34C1300"};

for (int i = 0; i < addresses.Length; i++)
{
    byte[] temp = Encoding.ASCII.GetBytes(addresses[i]);
    tree.AddLeaf(temp, true);
}

var root = Encoding.UTF8.GetString(tree.MerkleRootHash);
Console.WriteLine(root);

//0x2bd66355c24f675a8a9411593198b3aacaec256d58a2ce950c798b7e9a378f28


var proof = tree.GetProof(0);
Console.WriteLine(proof.ToJson());

/*[ "0x5931b4ed56ace4c46b68524cb5bcbf4195f1bbaacbe5228fbd090546c88dd229",
    "0x1f957db768cd7253fad82a8a30755840d536fb0ffca7c5c73fe9d815b1bc2f2f"]*/



var address = Encoding.ASCII.GetBytes(addresses[0]);
var addressHash = MerkleTree.keccakFromByte(address);
var isValid = tree.ValidateProof(proof, addressHash);
Console.WriteLine(isValid); //true

Contact

Contact beneyim@gmail.com with questions

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. 
.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.0.0 3,673 8/4/2022