npm run start async componentWillMount() {
await this.loadWeb3()
}
async loadWeb3() {
if(window.ethereum) {
window.web3= new Web3(window.ethereum)
await window.ethereum.enable()
} else if(window.web3) {
window.web3= new Web3(window.web3.currentProvider)
} else {
window.alert('No ETH browser detected, you can check out Metamask')
}
} async loadBlockChainData() {
// Load MetaMask & Account Number
const web3 = window.web3;
const account = await web3.eth.getAccounts();
this.setState({account: account[0]});
console.log(account)
// Load Network ID
const networkId = await web3.eth.net.getId();
// Load Tether Contract
const tetherData = Tether.networks[networkId];
if(tetherData) {
const tether = new web3.eth.Contract(Tether.abi, tetherData.address);
this.setState({tether});
let tetherBalance = await tether.methods.balanceOf(this.state.account).call();
this.setState({tetherBalance: tetherBalance.toString()});
}
else {
window.alert('Error! Tether contract not deployed!');
}
}