def solidity_resolve_address(hex_code, library_symbol, library_address):
 if library_address.startswith('0x'):
  raise ValueError('Address should not contain the 0x prefix')
 try:
  decode_hex(library_address)
 except TypeError:
  raise ValueError('library_address contains invalid characters, it must be hex encoded.')
 if ((len(library_symbol) != 40) or (len(library_address) != 40)):
  raise ValueError('Address with wrong length')
 return hex_code.replace(library_symbol, library_address)

def solidity_resolve_address ( hex_code , library_symbol , library_address ) : if library_address . startswith ( '0x' ) : raise ValueError ( 'Address should not contain the 0x prefix' ) try : decode_hex ( library_address ) except TypeError : raise ValueError ( 'library_address contains invalid characters, it must be hex encoded.' ) if ( ( len ( library_symbol ) != 40 ) or ( len ( library_address ) != 40 ) ) : raise ValueError ( 'Address with wrong length' ) return hex_code . replace ( library_symbol , library_address )
change the bytecode to use the given library address .