Exemple #1
0
    def wait_for_transaction_receipt(self, txid):
        LOG.info("Waiting for transaction receipt from the DID sidechain...")

        try:
            w3 = Web3(Web3.HTTPProvider(self.sidechain_rpc))
            tx_receipt = w3.eth.wait_for_transaction_receipt(txid,
                                                             timeout=30,
                                                             poll_latency=0.1)
            return {
                "tx_receipt": json.loads(Web3.toJSON(tx_receipt)),
                "err_type": None,
                "err_message": None
            }
        except TimeExhausted as e:
            LOG.info(
                f"Timed out while sending transactions to the DID sidechain: {str(e)}"
            )
            return {
                "tx_receipt": {},
                "err_type": "TimeExhausted",
                "err_message": str(e)
            }
        except Exception as e:
            LOG.info(
                f"Error while sending transactions to the DID sidechain: {str(e)}"
            )
            return {
                "tx_receipt": {},
                "err_type": "Exception",
                "err_message": str(e)
            }
Exemple #2
0
    def get_raw_transaction(self, txid):
        LOG.info(f"Retrieving transaction {txid} from the DID sidechain...")

        try:
            w3 = Web3(Web3.HTTPProvider(self.sidechain_rpc))
            tx = w3.eth.get_transaction_receipt(txid)
            return json.loads(Web3.toJSON(tx))
        except Exception as e:
            LOG.info(
                f"Error while getting raw transaction for a txid: {str(e)}")
            return None