Hi,
i give up … after like 8 hours of trying i really need to ask someone. I think the solution is easy but idk …
So Connecting Metamask is working perfectly… i can switch sites, refresh site everything no problem… web3 connections is still alive …
but if i am connected with walletconnect and trrustwallet for example, the login works perfectly… i even can call functions and stuff… but as soon as i refresh the website the web3 connection is lost, and the walletconnect - QR Code stuff appears …
How can i solve that?
here some of my code xD (the function init is called if website is loaded / refreshed)
async function login()
{
if (window.ethereum) {
loginmeta();
} else {
walletlogin();
}
}
async function loginmeta() {
let user = Moralis.User.current();
if (!user) {
user = await Moralis.authenticate();
}
callthewallet(user.get("ethAddress"));
document.querySelector("#prepare").style.display = "none";
document.querySelector("#connected").style.display = "block";
}
async function logOut() {
await Moralis.User.logOut();
document.querySelector("#prepare").style.display = "block";
document.querySelector("#connected").style.display = "none";
}
async function walletlogin() {
let user = Moralis.User.current();
if (!user) {
user = await Moralis.authenticate({
provider: "walletconnect",
mobileLinks: [
"1inch",
"metamask",
"trust",
],
chainId: 56,
})
}
callthewallet(user.get("ethAddress"));
window.localStorage.walletconnect = "walletconnect";
document.querySelector("#prepare").style.display = "none";
document.querySelector("#connected").style.display = "block";
}
async function init()
{
const user = await Moralis.User.current();
if(user)
{
if (window.localStorage.walletconnect) {
Moralis.enableWeb3({ provider: "walletconnect",chainId:56});
}
else
{
Moralis.enableWeb3();
}
callthewallet(user.get("ethAddress"));
document.querySelector("#prepare").style.display = "none";
document.querySelector("#connected").style.display = "block";
}
else
{
}
}
i really hope someone can help me … the dapp is almost done … cant belive i am to stupid for this rofl