Skip to content

Instantly share code, notes, and snippets.

@tinchoabbate
Created March 13, 2020 15:07
Show Gist options
  • Save tinchoabbate/23557831971e4f53219383d0f06df71a to your computer and use it in GitHub Desktop.
Save tinchoabbate/23557831971e4f53219383d0f06df71a to your computer and use it in GitHub Desktop.
Useful to pass a sequence of bytes to a function argument in Remix
#!/usr/bin/python3
import sys
if len(sys.argv) != 2 or len(sys.argv[1]) % 2 != 0:
print('Input missing or does not have even number of chars')
exit(1)
data = sys.argv[1]
data = data.replace('0x','')
final_string = ''
for i,k in zip(data[0::2],data[1::2]):
final_string += f'"0x{i}{k}",'
print(f'[{final_string[:-1]}]')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment