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/53531e0fd3fbc8ddda0acc8bf0fbd11e to your computer and use it in GitHub Desktop.
Save Hribek25/53531e0fd3fbc8ddda0acc8bf0fbd11e to your computer and use it in GitHub Desktop.
Generating IOTA addresses from a seed: API call Get_new_addresses()
# 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#0FF479CB6C0A
# Requirement: PyOTA library (!pip install pyota)
import iota
from pprint import pprint
# For this particular task the Node URL is not important as it will not be contacted at all
# However it has to be well-formatted URI
NodeURL = "https://nodes.thetangle.org:443"
MySeed = b"WKQDUZTGFKSSLACUCHHLZRKZBHSDSCEBHKUPDLKFBQALEBKDMFRPUQGZRXAADPG9TSRTZGGBZOFRJCFMM"
api=iota.Iota(NodeURL,
seed = MySeed) # if you do not specify a seed, PyOTA library randomly generates one for you under the hood
# Let's generate 3 addresses using default security level=2.
# It is deterministic function - it always generates same addresses as long as the Seed, Security Level and Index are the same
result = api.get_new_addresses(index=0,
count=3,
security_level=2)
pprint(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment