Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check for missing contract address in deployment receipt Update d… #200

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mdqst
Copy link

@mdqst mdqst commented Nov 19, 2024

Description:

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.

Changes made:

  • Added a condition to check whether the tx_receipt contains the key "contractAddress".
  • If the key is missing, the program now prints an error message and exits gracefully using exit(1).
  • If the key is found, the contract address is assigned to the contract_address variable, and the program continues.

Code:

tx_receipt = send_transaction(w3, transaction, operator)

# Check if the contract address is found in tx_receipt
if tx_receipt.get("contractAddress"):
    contract_address = tx_receipt["contractAddress"]
else:
    print("Error: Contract address not found.")
    exit(1)

Explanation of the fix:

This fix ensures that the program handles the scenario where the contract deployment fails and the contract address is not available in the transaction receipt. Without this check, the program would crash when trying to access the contract address. This fix improves the robustness of the contract deployment process and prevents potential runtime errors.

…emo.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.
@reviewable-StarkWare
Copy link

This change is Reviewable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants