What is the current best way to detect Metamask active account change in React DApp? I want to test my DApp with 2 accounts but when I switch, I see old data.
Apr 4, 2020, 6:28 AM
Does it cache msg.sender or what? Cuz when I do web3 call, I always get the same results, no matter if I switch account or not.
Example:
const registered = await myContract.methods.isRegistered().call();
it returns true even though I am sure that the second account is not registered,
Example:
const registered = await myContract.methods.isRegistered().call();
it returns true even though I am sure that the second account is not registered,
btw, I am using local Ganache blockchain that runs on port 7545
Apr 4, 2020, 7:42 AM
Do this
var account = web3.eth.accounts[0]; var accountInterval = setInterval(function() {
if (web3.eth.accounts[0] !== account)
{ account = web3.eth.accounts[0];
updateInterface();
}
}, 100);
var account = web3.eth.accounts[0]; var accountInterval = setInterval(function() {
if (web3.eth.accounts[0] !== account)
{ account = web3.eth.accounts[0];
updateInterface();
}
}, 100);
https://docs.metamask.io/guide/accessing-accounts.html
Anyone know API I can get price of coin and other data at A PARTICULAR TIME
Apr 4, 2020, 10:46 AM