'Return a proxy for calling a contract method with automatic encoding of
argument and decoding of results.'

@staticmethod
def method_factory(tx_or_call, function_name):

    def kall(self, *args, **kwargs):
        key = kwargs.get('sender', k0)
        result = tx_or_call(sender=key, to=self.address, value=kwargs.get('value', 0), data=self.translator.encode(function_name, args), startgas=kwargs.get('startgas', STARTGAS), gasprice=kwargs.get('gasprice', GASPRICE))
        if (result is False):
            return result
        if (result == ''):
            return None
        o = self.translator.decode(function_name, result)
        return (o[0] if (len(o) == 1) else o)
    return kall
