我正在调用以下函数:
test: function()
{
alert("test1");
let meta
LoyaltyCard.deployed().then(function (instance) {
meta = instance
alert("test");
}).catch(function (e) {
alert(e);
})
//})
}
并在调用时如下:
<button type="button" onclick="App.test()">TEST</button>
不幸的是,在调用此部分:
}).catch(function (e) {
alert(e);
我得到以下内容:
错误:尚未将LoyaltyCard部署到检测到的网络(网络/工件不匹配)
有谁知道为什么?
在与web3库交互时,必须使用await和async。下面是我用来获取使用角度6的已部署合同实例的示例。
async getInstance() {
await this.web3Service.artifactsToContract(artifacts)
.then((uLoanAbstraction) => {
this.LoanAbstraction = uLoanAbstraction;
});
this.deployedLoans = await this.uLoanAbstraction.deployed();
// Later in the app i use this.deployedLoans to interact with the smart contract
}