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

Smart Contract cli.transact_and_wait returning nil, instead for error message #223

Open
kyleboureston opened this issue Mar 10, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@kyleboureston
Copy link

kyleboureston commented Mar 10, 2023

Hello,

When submitting transact_and_wait to a remote connect, I get nil instead of an error message. Would love a message so I can debug properly!

PS: to add, even when I get a Success transaction, I am still getting nil

Thank you

@q9f q9f added the bug Something isn't working label Mar 25, 2023
@q9f
Copy link
Owner

q9f commented Mar 25, 2023

Yes, this means that your transaction didn't succeed. I just reviewed the logic and we throw an error, if something goes wrong and return a hash if it succeeds. However, currently, there is no logic to inform you if something happens to the transaction execution in the virtual machine.

I'll think about a better handling here.

@zackisaacs
Copy link

zackisaacs commented May 19, 2023

I've noticed the problem (transact_and_wait returns nil) when connecting to infura, even when the transaction succeeds. I believe the problem is not wait_for_tx(transact(contract, function, *args, **kwargs)) fails here:

hash = wait_for_tx(transact(contract, function, *args, **kwargs))

but that tx_succeeded? hash returns false shortly thereafter here:

return hash if tx_succeeded? hash

My guess is that the transaction receipt doesn't propagate to the network readers used by infura quickly enough when calling eth_get_transaction_receipt(hash) here:

tx_receipt = eth_get_transaction_receipt(hash)

Writing and then not being able to read right after is a pretty common race condition. Could solve by updating tx_succeeded?(hash) to retry if tx_receipt["result"].nil? == true here:

!tx_receipt.nil? && !tx_receipt["result"].nil? && tx_receipt["result"]["status"] == "0x1"

If this is something you'd like to see, I'd be happy to submit a PR.

@q9f
Copy link
Owner

q9f commented May 22, 2023

I'll gladly review such a PR, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants