Skip to content

Instantly share code, notes, and snippets.

@elmato
Created January 6, 2022 01:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elmato/ec2ff3361c98d5be7f704705fc71a96e to your computer and use it in GitHub Desktop.
Save elmato/ec2ff3361c98d5be7f704705fc71a96e to your computer and use it in GitHub Desktop.
import sys
from binascii import hexlify
from ueosio.ds import DataStream, symbol_code_to_uint64
def eos_token_to_erc20(account, symbol_code, precision):
v=symbol_code_to_uint64(symbol_code)<<8|int(precision)
ds=DataStream()
ds.pack_uint64(v)
ds.pack_name(account)
return "0x"+hexlify(ds.getvalue()).ljust(40,b'0').decode('ascii')
if __name__ == '__main__':
if len(sys.argv) < 4:
print("usage:\n{0} eosio.token EOS 4".format(sys.argv[0]))
sys.exit(1)
print(eos_token_to_erc20(sys.argv[1], sys.argv[2], sys.argv[3]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment