-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendTX.py
More file actions
50 lines (45 loc) · 1.4 KB
/
sendTX.py
File metadata and controls
50 lines (45 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'''
Run using python 2.7 because PYOTA is compatible with Python 2.7 but not Python 3.7
'''
from iota import Iota
from iota import ProposedTransaction
from iota import Address
from iota import Tag
from iota import TryteString
from json import load
def sendTX(msg):
'''
PURPOSE: send transaction to the Tangle
INPUT:
address from a seed different than the one in this script
OUTPUT:
TX to devnet
'''
seed = 'SEED99999999999999999999999999999999999999999999999999999999999999999999999999999'
address = 'ADDRESS9FROM9DIFFERENT9SEED999999999999999999999999999999999999999999999999999999'
api = Iota('https://nodes.devnet.iota.org:443', seed)
tx = ProposedTransaction(
address=Address(address),
message=TryteString.from_unicode(msg),
tag=Tag('YOURTAG'),
value=0
)
try:
tx = api.prepare_transfer(transfers=[tx])
except Exception as e:
print("Check prepare_transfer ", e)
raise
try:
result = api.send_trytes(tx['trytes'],depth=3,min_weight_magnitude=9)
except:
print("Check send_trytes")
if __name__=="__main__":
f = open("airquality.csv","r")
msg = f.readlines()[-1]
msg = msg.strip("\n")
print(msg)
try:
sendTX(msg)
except e:
print("Check devnet",e)
f.close()