i am making my university fyp on web3, i just want to call the account number inside "currentAccount" in render so that i can add if condition in it
async loadBlockchainData() {
await window.ethereum.enable()
const accounts = await web3.eth.getAccounts();
web3.eth.defaultAccount = accounts[0];
console.log(accounts);
console.log("acc", accounts[0]);
this.setState({ account: accounts[0] });
const currentAccount = (accounts[0]);
}
this currentAccount have the account number which i going to use in if condition to login or not in render:
render() {
// const isEnabled = this.canBeSubmitted();
const loginss = "() => history.push('/form')";
return (
<div className={classes.login}>
<div className="App">
<header className="App-header">
<section class="ftco-section">
<div class="container">
<div class="login100-form validate-form">
<span class="login100-form-title p-b-43">Welcome!</span>
<div class="wrap-input100 rs1 validate-input">
<input
class="input100"
type="text"
readonly
name="username"
/>
<span class="label-input100">LOGIN WITH METAMASK</span>
</div>
<div class="container-login100-form-btn">
<button onClick={loginss} class="login100-form-btn">
Connect
{/* {!isConnecting && "Connect"}
{isConnecting && "Loading..."} */}
</button>
</div>
</div>
</div>
</section>
</header>
</div>
</div>
);
}
Via Active questions tagged javascript - Stack Overflow https://ift.tt/rvyiqQR
Comments
Post a Comment