def hex_encode_abi_type(abi_type, value, force_size=None):
    """
    Encodes value into a hex string in format of abi_type
    """
    validate_abi_type(abi_type)
    validate_abi_value(abi_type, value)

    data_size = force_size or size_of_type(abi_type)
    if is_array_type(abi_type):
        sub_type = sub_type_of_array_type(abi_type)
        return "".join([remove_0x_prefix(hex_encode_abi_type(sub_type, v, 256)) for v in value])
    elif is_bool_type(abi_type):
        return to_hex_with_size(value, data_size)
    elif is_uint_type(abi_type):
        return to_hex_with_size(value, data_size)
    elif is_int_type(abi_type):
        return to_hex_twos_compliment(value, data_size)
    elif is_address_type(abi_type):
        return pad_hex(value, data_size)
    elif is_bytes_type(abi_type):
        if is_bytes(value):
            return encode_hex(value)
        else:
            return value
    elif is_string_type(abi_type):
        return to_hex(text=value)
    else:
        raise ValueError(
            "Unsupported ABI type: {0}".format(abi_type)
        )
def hex_encode_abi_type ( abi_type , value , force_size = None ) : validate_abi_type ( abi_type ) validate_abi_value ( abi_type , value ) data_size = force_size or size_of_type ( abi_type ) if is_array_type ( abi_type ) : sub_type = sub_type_of_array_type ( abi_type ) return "" . join ( [ remove_0x_prefix ( hex_encode_abi_type ( sub_type , v , 256 ) ) for v in value ] ) elif is_bool_type ( abi_type ) : return to_hex_with_size ( value , data_size ) elif is_uint_type ( abi_type ) : return to_hex_with_size ( value , data_size ) elif is_int_type ( abi_type ) : return to_hex_twos_compliment ( value , data_size ) elif is_address_type ( abi_type ) : return pad_hex ( value , data_size ) elif is_bytes_type ( abi_type ) : if is_bytes ( value ) : return encode_hex ( value ) else : return value elif is_string_type ( abi_type ) : return to_hex ( text = value ) else : raise ValueError ( "Unsupported ABI type: {0}" . format ( abi_type ) )
Encodes value into a hex string in format of abi_type