I know their might be examples online, but they do not really solve my issue.

So let us say I have the code below:

  this.factoryContract = new ethers.Contract(

  this.factoryContract.createChild()// how can I get transaction hash instead of waiting for it inside the "then(){}" callback?
    .then(()=>{/*do things here**/});
    .catch(()=>{/*do things here**/});
  • What do you mean by "before sending transaction"?! Before user confirm it or being mined?! Sep 14, 2021 at 22:47
  • Before it is mined. I mean just after it is signed by the user but before sending it to the blockchain to be mined.
    – YulePale
    Sep 15, 2021 at 2:15

2 Answers 2


I guess I found what you want But not sure.

async function creatChildContract(){
   tx = await this.factoryContract.createChild();
   tx.hash //returns hash of the transaction which user just signed.
  • No, I do not want to await for the transaction to be mined.
    – YulePale
    Sep 15, 2021 at 13:13
  • No, this await is waiting for user to sign the transaction, not transaction to be mined! Sep 15, 2021 at 15:59
  • My bad. You are right. :) Thank you.
    – YulePale
    Sep 16, 2021 at 3:17
  • No problem, my friend. Best regards. Sep 16, 2021 at 8:21

Finally found an answer to my problem:

async function creatChildContract(){
        // here you can access the transaction hash before it is mined
        // you do not have to wait, once the transaction is confirmed, the hash is available.
    .catch(()=>{/*do things here**/})

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.