async initWeb3Account(callback) {
if (window.ethereum) {
this.provider = window.ethereum;
// 请求连接demo.
try {
await window.ethereum.enable();
} catch (error) {
console.error("User denied account access");
}
}
this.web3 = new Web3(this.provider);
this.web3.provider = this.provider
this.web3.eth.getAccounts((err, accs) => {
if (err != null) {
console.error("无法获取账号, 是否安装了 Metamask");
this.message = "";
return;
}
if (accs.length === 0) {
console.error("无法获取账号,Metamask 时候正确配置.");
return;
}
// this.account = accs[0]
})
},