Skip to content

Instantly share code, notes, and snippets.

@Hribek25
Last active September 24, 2019 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hribek25/5216c16c21ae7fa5a523c83a5ab107f8 to your computer and use it in GitHub Desktop.
Save Hribek25/5216c16c21ae7fa5a523c83a5ab107f8 to your computer and use it in GitHub Desktop.
Validating IOTA address
// 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#C65223B0864A
// Requirement: Tangle.Net library (!nuget install Tangle.Net)
#r "Tangle.Net.dll"
using Tangle.Net.Entity;
using Tangle.Net.Utils;
//address including checksum
var InputAddr = "CYJV9DRIE9NCQJYLOYOJOGKQGOOELTWXVWUYGQSWCNODHJAHACADUAAHQ9ODUICCESOIVZABA9LTMM9RWTHBIRSXTA";
if (!InputValidator.IsTrytes(InputAddr) || InputAddr.Length != 90)
{
Console.WriteLine("Not valid input address incl. checksum was given.");
} else {
var Adr = new Address(InputAddr);
Console.WriteLine("Input address incl checksum:");
Console.WriteLine(InputAddr);
Console.WriteLine("Is it valid addr based on checksum? " + Adr.HasValidChecksum().ToString());
Console.WriteLine("Input address excl checksum:");
Console.WriteLine(Adr.ToString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment