And please share your logs/messages.
Also check your chain settings in the metamask
And please share your logs/messages.
Also check your chain settings in the metamask
Now it is telling me my wallet is not installed, but i get right chain id now (when i change network)
Do i share logs from console or dashboard ?
Sorry, my bad. In your case you need to use await Moralis.isMetaMaskInstalled();
Instead of const isWeb3Active = Moralis.ensureWeb3IsInstalled()
Now it seems it is working thanks for help !
You are welcome! Happy BUIDLing
One question.
1. What do you get back if you connect to a moralis website with avax chain and write in console chainID = await Moralis.getChainId();
. I get back 1. This is very problematic, because when user logs in I get and compute everything for eth chain (cus 1 is returned before). For all other chains work perfectly.
Moralis.onChainChanged(function(chain){
currentChain = chian;
})
return completly different chian id than chainID = await Moralis.getChainId();
(it returns same chain but with different naming -> 1 and 0x1) ?
1
is decimal format
0x1
is hex format
If i use Moralis.getChainId()
on Avalance I get 1
too. I don’t know why
Okay, I also found the difficulty that if you want to use .getChainId
you need to enable web3.
I suggest you to use the classic way in your case:
if (window.ethereum) {
const chainId = window.ethereum.chainId;
}
The method will return you chainId in hex format 0xa86a
Now it is fully working. Thanks again !
Happy to help
the function switchNetwork() eth to avax doesn’t work for me .but the other chains work.
Hey @ihxx
Please for each question open a new topic
But I guess we can easy solve your problem:
Moralis.switchNetwork("0xa86a")
works nice, I just tested it. If your Metamask doesn’t have avalanche it will not switch to it. You need to add it manually.
Take a look at https://docs.moralis.io/moralis-server/web3/web3#addnetwork
getChainId() worked properly for avalanche past couple of days. but today all of a sudden, it started returning 1 … Please kindly take a look. This kind of bug is a bit scary … thank you
maybe MetaMask is connected to ETH network? I tested now few networks and it looks like it works fine.
getChainId() works for all networks besides avalanche. Please kindly take a look at the other users’ messages, too. We all have the same issue. getChainId() returns 1 for avalanche. thank you
We will notify when we will find a solution for this and add it to the library
It really depends from which chain are you switching to avalanche
from which chain are you switching?
you can try to use id = await web3.eth.getChainId()
for now