From b6ac82258eaff825b70dad5783c0cc5db6c4b75e Mon Sep 17 00:00:00 2001 From: Dmitry <98899785+mdqst@users.noreply.github.com> Date: Tue, 19 Nov 2024 13:49:01 +0300 Subject: [PATCH] Add check for missing contract address in deployment receipt Update demo.py In some cases, if the contract deployment is unsuccessful, the tx_receipt["contractAddress"] variable might be None. This can lead to errors when trying to use it later in the code. To prevent this issue, I have added a check before accessing the contractAddress key in the transaction receipt. --- src/demo/amm_demo/demo.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/demo/amm_demo/demo.py b/src/demo/amm_demo/demo.py index 3f2b8bba..ee3d7bf3 100644 --- a/src/demo/amm_demo/demo.py +++ b/src/demo/amm_demo/demo.py @@ -87,6 +87,14 @@ def deploy_contract(batch_prover: BatchProver, w3: Web3, operator: BaseAccount) ) print("Deploying the AMM demo smart contract...") tx_receipt = send_transaction(w3, transaction, operator) + + # Check if the contract address is found in the tx_receipt + if tx_receipt.get("contractAddress"): + contract_address = tx_receipt["contractAddress"] + else: + print("Error: Contract address not found.") + exit(1) + assert ( tx_receipt["status"] == 1 ), f'Failed to deploy contract. Transaction hash: {tx_receipt["transactionHash"]}.'