Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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_python.ipynb.html#C65223B0864A
# Requirement: PyOTA library (!pip install pyota)
import iota
import sys
from pprint import pprint
InputAddr = b"CYJV9DRIE9NCQJYLOYOJOGKQGOOELTWXVWUYGQSWCNODHJAHACADUAAHQ9ODUICCESOIVZABA9LTMM9RWTHBIRSXTA"
if len(InputAddr)!=90:
print("Incorrect lenght of the given address. Please, use an address including checksum.")
exit(2)
try:
# address including checksum
Adr2 = iota.Address(InputAddr)
except :
print("Not valid input address given")
sys.exit(1)
pprint("Input address incl checksum:")
pprint(Adr2)
print("Is it valid addr based on checksum? %s" % (Adr2.is_checksum_valid()))
print("\nInput address excl checksum:")
pprint(Adr2[:81]) # return only first 81 characters
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.