Reputation: 1
I stored the string values into the Python list. Then I want to pass this list values to Solidity where the data type needed is byte32[]. So the question is how to declare a char 'b' without indicating '' and append it in front of every element?
The python variable
name = ['Ken','Rose']
The name variable that need to be format as below
sol_par = [b'Ken',b'Rose']
Upvotes: 0
Views: 282
Reputation: 343
Have you tried:
sol_par = []
for word in name:
sol_par.append(bytes(x, 'utf8'))
(Edited for correct bytes
syntax)
Upvotes: 1
Reputation: 2094
You can use the map
function with str.encode
:
name = ['Ken','Rose']
sol_par = list(map(str.encode, name))
Upvotes: 1