def descripe_contract(contract): print("invoking contract - %s" % contract.Name.decode('utf-8')) functionCode = contract.Code parameters = functionCode.ParameterList method_signature = [] for p in parameters: method_signature.append("{ %s } " % ToName(p)) rettype = ToName(functionCode.ReturnType) print("method signature %s --> %s" % (' '.join(method_signature), rettype))
def ToJson(self): """ Convert object members to a dictionary that can be parsed as JSON. Returns: dict: """ parameters = self.ParameterList.hex() paramlist = [ToName(ContractParameterType.FromString(parameters[i:i + 2]).value) for i in range(0, len(parameters), 2)] return { 'hash': self.ScriptHash().To0xString(), 'script': self.Script.hex(), 'parameters': paramlist, 'returntype': ToName(self.ReturnType) if type(self.ReturnType) is int else ToName(int(self.ReturnType)) }
def ToJson(self): jsn = {} jsn['type'] = ToName(self.Type) return jsn