Iota Asked by degr8sid on August 21, 2021
I am using one command tangle. The tangle is running on Ubuntu machine. From the list of APIs given for IRI node, I’m trying to broadcast a transaction. For this, the first step is to get getTransactionsToApprove which returns trunkTransaction and branchTransaction and I have to assign that value to attachToTangle API.
I am getting the correct output from getTransactionsToApprove API:
{'trunkTransaction': 'NTCYZTAJTVJIAQW9JXUJCACYPHNMESWGWTANQQZSLGHQTKWGDOYHAHBETUXKNAMMWYDTILDWLPQTOX999', 'branchTransaction': 'NTCYZTAJTVJIAQW9JXUJCACYPHNMESWGWTANQQZSLGHQTKWGDOYHAHBETUXKNAMMWYDTILDWLPQTOX999', 'duration': 2}
The problem is when I am assigning those values to attachToTangle API, I’m getting this error:
HTTP Error 500: Internal Server Error
My code is:
import urllib.request
import urllib.parse
import json
import requests
trytes = "hello world!"
url="http://mydnsname:14265"
headers = {
'Content-Type': 'application/json',
"Accept": "application/json",
'X-IOTA-API-Version': '1'
}
#get transactions
command = {
"command": "getTransactionsToApprove",
"depth": 4
}
data= json.dumps(command).encode("utf-8")
request = urllib.request.Request(url, data, headers)
try:
returnData = urllib.request.urlopen(request).read()
jsonData = json.loads(returnData)
print (jsonData)
except urllib.error.URLError as e:
ResponseData = e.reason
print (e)
#attach to tangle
command = {
"command": "attachToTangle",
"trunkTransaction": jsonData['trunkTransaction'],
"branchTransaction": jsonData['branchTransaction'],
"minWeightMagnitude": 9,
"trytes": trytes
}
data= json.dumps(command).encode("utf-8")
request = urllib.request.Request(url, data, headers)
try:
returnData = urllib.request.urlopen(request).read()
jsonData = json.loads(returnData)
print (jsonData)
except urllib.error.URLError as e:
ResponseData = e.reason
print (e)
Any help is much appreciated.
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP