如何将两个合同更新链接在一起?
下面的代码用于单独更新每个更新,但我必须批准Metamask中的第一个更新,然后等待它完成,然后其他更新请求在Metamask中得到确认:
await vaultcontract.methods.update7Day([update7day]).send({from: account}).then(function(receipt){
document.getElementById("7dayupdated").innerText = "updated";
});
await vaultcontract.methods.update30Day([update30day]).send({from: account}).then(function(receipt){
document.getElementById("30dayupdated").innerText = "updated";
});我怎样才能同时处理一笔交易呢?
发布于 2022-06-19 12:52:50
Promise.all([
vaultcontract.methods.update7Day([update7day]).send({from: account}),
vaultcontract.methods.update30Day([update30day]).send({from: account})
]).then( _ => {
// variable name is _ (underscore) because you don't use it
document.getElementById("7dayupdated").innerText = "updated";
document.getElementById("30dayupdated").innerText = "updated";
});https://stackoverflow.com/questions/72676981
复制相似问题