Instantly share code, notes, and snippets.

Embed
What would you like to do?
Preparing IOTA transactions to be broadcasted
# 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#445C2B9485C6
# Requirement: PyOTA library (!pip install pyota)
import iota
from datetime import datetime
from pprint import pprint
MySeed = b"HGW9HB9LJPYUGVHNGCPLFKKPNZAIIFHZBDHKSGMQKFMANUBASSMSV9TAJSSMPRZZU9SFZULXKJ9YLAIUA"
TargetAddress1 = b"CXDUYK9XGHC9DTSPDMKGGGXAIARSRVAFGHJOCDDHWADLVBBOEHLICHTMGKVDOGRU9TBESJNHAXYPVJ9R9"
TargetAddress2 = b"CYJV9DRIE9NCQJYLOYOJOGKQGOOELTWXVWUYGQSWCNODHJAHACADUAAHQ9ODUICCESOIVZABA9LTMM9RW"
NowIs = datetime.now() # get a actual date & time - just to have some meaningfull info
# preparing transactions
pt = iota.ProposedTransaction(address = iota.Address(TargetAddress1), # 81 trytes long address
message = iota.TryteString.from_unicode('Here comes a first message. Now is %s' % (NowIs)),
tag = iota.Tag(b'HRIBEK999IOTA999TUTORIAL'), # Up to 27 trytes
value = 0)
pt2 = iota.ProposedTransaction(address = iota.Address(TargetAddress2), # 81 trytes long address
message = iota.TryteString.from_unicode('Here comes a second message. Now is %s' % (NowIs)),
tag = iota.Tag(b'HRIBEK999IOTA999TUTORIAL'), # Up to 27 trytes
value = 0)
# besides the given attributes, library also adds a transaction timestamp
print("Created transaction objects:\n")
pprint(vars(pt))
print("\n")
pprint(vars(pt2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment