Created
January 6, 2022 01:27
-
-
Save elmato/ec2ff3361c98d5be7f704705fc71a96e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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