Security analysis tool for EVM bytecode. Supports smart contracts built for Ethereum, Hedera, Quorum, Vechain, Roostock, Tron and other EVM-compatible blockchains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mythril/rpc/utils.py

39 lines
687 B

from .constants import BLOCK_TAGS
def hex_to_dec(x):
'''
Convert hex to decimal
'''
return int(x, 16)
def clean_hex(d):
'''
Convert decimal to hex and remove the "L" suffix that is appended to large
numbers
'''
return hex(d).rstrip('L')
def validate_block(block):
if isinstance(block, str):
if block not in BLOCK_TAGS:
raise ValueError('invalid block tag')
if isinstance(block, int):
block = hex(block)
return block
def wei_to_ether(wei):
'''
Convert wei to ether
'''
return 1.0 * wei / 10**18
def ether_to_wei(ether):
'''
Convert ether to wei
'''
return ether * 10**18