def _send_transaction(self, data): """ Sends a transaction to the Ethereum client. data: the data to be sent. """ return ethclient.send_transaction( _from=self.from_address, to=self.to_address, data=encode_api_data(data), gas=100 # TODO: modify? )
def _send_transaction(self, data): """ Send a transaction. data: the transactions data. """ return ethclient.send_transaction( _from=self.from_address, to=self.to_address, data=encode_api_data(data), gas=2000000, # TODO deal with gas limit more sensibly )
def _get_logs(self, topics, event_name=None): """ Get logs of the events that occur. topics: a list of topics to search based on event_name: the name of the event """ # set topic to the ID if the name is specified if event_name == None: event_topic = None else: event_topic = self._get_event_id_by_name(event_name) # add the event type to the topics topics = [event_topic] + topics # encode topics to be sent to the eth client topics = [encode_api_data(topic) for topic in topics] # gets logs from eth client logs = ethclient.get_logs( from_block='earliest', address=self.address, topics=topics, ) # decode logs using the ABI decoded_logs = [] for log in logs: logobj = processblock.Log( log['address'][2:], [big_endian_to_int(decode_hex(topic[2:])) for topic in log['topics']], decode_hex(log['data'][2:]) ) decoded_log = self._contracttranslator.listen(logobj, noprint=True) decoded_logs.append(decoded_log) return decoded_logs
def _get_logs(self, topics, event_name=None): """ Get logs (events). topics: a list of topics to search for. event_name: the name of the event. """ # Set the event topic to the event ID if the event name is specified. if event_name is None: event_topic = None else: event_topic = self._get_event_id_by_name(event_name) # Prepent the event type to the topics. topics = [event_topic] + topics # Encode topics to be sent to the Ethereum client. topics = [encode_api_data(topic) for topic in topics] # Get logs from Ethereum client. logs = ethclient.get_logs( from_block='earliest', address=self.address, topics=topics, ) # Decode logs using the contract ABI. decoded_logs = [] for log in logs: logobj = processblock.Log( log['address'][2:], [big_endian_to_int(decode_hex(topic[2:])) for topic in log['topics']], decode_hex(log['data'][2:]) ) decoded_log = self._contracttranslator.listen(logobj, noprint=True) decoded_logs.append(decoded_log) return decoded_logs
def _get_logs(self, topics, event_name=None): """ Get logs (events). topics: a list of topics to search for. event_name: the name of the event. """ # Set the event topic to the event ID if the event name is specified. if event_name is None: event_topic = None else: event_topic = self._get_event_id_by_name(event_name) # Prepent the event type to the topics. topics = [event_topic] + topics # Encode topics to be sent to the Ethereum client. topics = [encode_api_data(topic, padding=32) for topic in topics] # Get logs from Ethereum client. logs = ethclient.get_logs( from_block='earliest', address=self.address, topics=topics, ) # Decode logs using the contract ABI. decoded_logs = [] for log in logs: logobj = processblock.Log(log['address'][2:], [ big_endian_to_int(decode_hex(topic[2:])) for topic in log['topics'] ], decode_hex(log['data'][2:])) decoded_log = self._contracttranslator.listen(logobj, noprint=True) decoded_logs.append(decoded_log) return decoded_logs