Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
IOTA address and checksum
// The snippet is a part of the IOTA Developer Essentials project. You can reach it at https://hribek25.github.io/IOTA101/
// Complete description and story behind the snippet is available at: https://hribek25.github.io/IOTA101/Allchapters_csharp.ipynb.html#39B011574CF0
// Requirement: Tangle.Net library (!nuget install Tangle.Net)
#r "Tangle.Net.dll"
using Tangle.Net.Entity;
var myAddr = new Address("CYJV9DRIE9NCQJYLOYOJOGKQGOOELTWXVWUYGQSWCNODHJAHACADUAAHQ9ODUICCESOIVZABA9LTMM9RW"); //some IOTA address
Console.WriteLine("Original input excl. checksum address:");
Console.WriteLine(myAddr.ToString());
Console.WriteLine("Length: " + myAddr.ToString().Length);
var AdrIncludingChecksum = new Address(myAddr.ToString() + Checksum.FromAddress(myAddr).ToString()); //generate checksum for the given address and return new address instance that includes checksum
// There is a function Withchecksum() but it did not work when tested
Console.WriteLine("Input address including checksum:");
Console.WriteLine(AdrIncludingChecksum.ToString() + AdrIncludingChecksum.Checksum.ToString()); //Library still thinks of the address as 2 separate components
Console.WriteLine("Length incl checksum: " + (AdrIncludingChecksum.ToString().Length + AdrIncludingChecksum.Checksum.ToString().Length));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.