3

I am trying to send a list data to IOTA Ledger as follow

client = iota_client.Client()

message_temperature = client.message( index="Pasteur1_Tempdata", data=temp_list )

where my temp_list is [725, 702, 746, 734, 715, 722, 706, 746, 737, 714, 741, 732, 715, 726, 704, 749, 734, 715, 722, 706, 746, 737, 714, 741, 732, 715, 715, 722, 706, 746, 737, 714, 741, 732, 715, 726, 704, 749, 734]

which gives overflowerror as mentioned in subject. But it manage to send two digit integer list.

What is the limitation here is iota_client library do not support conversion of large integers?

5
  • 1
    What's your data type of temp_list? You'd need to convert to bytes and send it. .encode("utf8")
    – Ani
    Mar 21 at 13:32
  • Thank You for responding. temp_list is type list[int]. Actually I want to send float values like 72.5, 70.2 etc. (diving 725/10 after receiving) I am trying to understand here that I am able to send two digit integer without encoding what is the reason behind that it won't take 3 digit integer. As you suggested I will try converting it to bytes first.
    – K.Baig
    Mar 28 at 21:32
  • It'll work any number of digits. You need to encode the entire thing. The way it's coming, the message will treat each object in array as separate entity. Hence would fail for numbers greater than 255.
    – Ani
    Mar 29 at 7:50
  • 2
    Thank you. it worked. Here is the code I used *****encoding******* client = iota_client.Client() data = [72.5, 70.3, 69.5, 55.2, 45.6, 89.6, 42.2] # encoding utf string into list of bytes data_str = str(data).encode('utf-8') message = client.message( index="some_data_index", data=data_str *******Decoding***** client = iota_client.Client() message = client.get_message_data("your message id") data = message['payload']['indexation'][0]['data'] data_bytes = bytes(data) decoded_str = data_bytes.decode('utf-8')
    – K.Baig
    Mar 30 at 22:25
  • 1
    Perfect. Could you also add that as an answer so it might help others?
    – Ani
    Mar 31 at 5:11

1 Answer 1

0

From K.Baig's comment:

Thank you. it worked. Here is the code I used

Encoding

client = iota_client.Client()

data = [72.5, 70.3, 69.5, 55.2, 45.6, 89.6, 42.2]

# encoding utf string into list of bytes
data_str = str(data).encode('utf-8')
message = client.message(index="some_data_index", data=data_str)

Decoding

client = iota_client.Client()

message = client.get_message_data("your message id")

data = message['payload']['indexation'][0]['data']
data_bytes = bytes(data)

decoded_str = data_bytes.decode('utf-8') 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.