-
My React Native (0.64) uses ethers (5.4.6) to deploy contract. The current code can handle when deploy throws an error and success by using try catch and listening to event. However if the deployment has failed, how to detect the failure? Here is the code:
|
Beta Was this translation helpful? Give feedback.
Answered by
zemse
Sep 3, 2021
Replies: 1 comment 4 replies
-
You can get the deploy transaction and check its success: const contractFS = await factory.deploy(value, item.name, item.id);
const tx = contractFS.deployTransaction
const receipt = await provider.getTransactionReceipt(tx.hash);
receipt.success // false means the deploy tx failed, due to some sort of revert. There can be other reasons for deploy failure like network failure, seems that it will be caught in your try/catch. |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
emclab
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can get the deploy transaction and check its success:
There can be other reasons for deploy failure like network failure, seems that it will be caught in your try/catch.