我知道他们可能是网上的例子,但他们并没有真正解决我的问题。
所以让我们说,我有下面的代码:
this.factoryContract = new ethers.Contract(
"factoryContractAddress",
"factoryContractABI",
signer
);
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**/});发布于 2021-09-15 09:11:25
我想我找到了你想要的但不确定。
async function creatChildContract(){
tx = await this.factoryContract.createChild();
tx.hash //returns hash of the transaction which user just signed.
}发布于 2021-09-15 13:46:05
终于找到了我的问题的答案:
async function creatChildContract(){
this.factoryContract.createChild()
.then((log)=>{
console.log(log.hash);
// 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**/})
})https://ethereum.stackexchange.com/questions/109922
复制相似问题