How to hide my userInfo element

yeah definitely i will tell him to audit it, a friend of mine got that code

So i want to ask, is it possible to create a presale smart contract for an NFT token?

What about the claim token function?

Watch this. It may help you out

Create a NFT Presale smart contract - YouTube

1 Like

Alright thanks i will do that and check it out

Looks like the buyWithBNB function returns the tokens immediately

1 Like

What if i don’t want to use moralis for building a presale smart contract for a token how do i do that? Because i want to learn how to build a presale smart contract for any token out there in crypto space

I told my friend that the fucntion on the buyBNB gives out the token immediately into his wallet but he said the owner wallet token is not reducing, what is happening to his code or is it just a normal way for owner wallet not deducted or reduced when holders buys the presale.

You cannot develop Smart Contracts with Moralis. You need to learn Solidity first.
Checkout the Moralis YouTube Channel! You will learn fast

1 Like

Okay can you get me the youtube link so i can go through it

Moralis Web3 - YouTube

1 Like

Bro can i have your contact, how do i connect with you on other social platform apart from moralis?

You can write here in the forum or on Discord.
LocoTheDev#2383 but only contact me please for Moralis Support.

1 Like

Hello bro, how do i add the unlinked function to my code below?

const serverUrl = "https://mzrhanzmogsu.moralishost.com:2053/server";
const appId = "gFnTLmvgt8ZDUYMXF80FIonsCRqosKxXcfzmO2bM";
Moralis.start({ serverUrl, appId });

async function hide_buttons() {
    let user = await Moralis.User.current();
    if (!user) {
        document.getElementById("btnConnect").style.display = "block";
        document.getElementById("btnUserInfo").style.display = "none";
        document.getElementById("btnLogout").style.display = "none";
        document.getElementById("userInfo").style.display = "none";
    } else {
        document.getElementById("btnUserInfo").style.display = "block";
        document.getElementById("btnConnect").style.display = "none";
        document.getElementById("btnLogout").style.display = "block";
    }
}

hide_buttons();

async function login() {
    let user = Moralis.User.current();
    if (!user) {
        try {
            user = await Moralis.authenticate({
                signingMessage: "Welcome to GrandPaDoge NFT MarketPlace",
            });
        } catch (error) {
            alert(
                (error =
                    "Please consider installing Metamask to connect to MrGrandPaDoge NFT MarketPlace")
            );
        }
    }
    console.log("logged in user:", user);
    hide_buttons();
    const isWeb3Active = Moralis.ensureWeb3IsInstalled();

    if (isWeb3Active) {
        console.log("Activated");
    } else {
        async function enable() {
            await Moralis.enable();
        }
    }
}

async function logOut() {
    await Moralis.User.logOut();
    console.log("logged out");
    hide_buttons();
}

async function openuserInfo() {
    user = await Moralis.User.current();
    hide_buttons();
    if (user) {
        document.getElementById("userInfo").style.display = "block";
    } else {
        login();
    }
}

async function closeuserInfo() {
    user = await Moralis.User.current();
    hide_buttons();
    if (user) {
        document.getElementById("userInfo").style.display = "none";
    } else {
        logOut();
    }
}

Moralis.onAccountsChanged(async function(accounts) {
    const confirmed = confirm(
        "Are you sure you want to link this address to your account?"
    );
    if (confirmed) {
        await Moralis.link(accounts[0]);
        alert("Address added!");
        console.log("Address linked");
    }
});

document.getElementById("btnConnect").onclick = login;
document.getElementById("btnLogout").onclick = logOut;
document.getElementById("btnUserInfo").onclick = openuserInfo;
document.getElementById("btnCloseUserInfo").onclick = closeuserInfo;

This is the linked function code bro

Moralis.onAccountsChanged(async function(accounts) {
let user = Moralis.User.current();
if(user) {
    const confirmed = confirm(
        "Are you sure you want to link this address to your account?"
    );
    if (confirmed) {
        await Moralis.link(accounts[0]);
        alert("Address added!");
        console.log("Address linked");
    }
}
});

Add this function within your script tag

I want to set an unlinked function to the code how do i do that?

await Moralis.unlink(address);

Where should i add this function?

Where ever you want to unlink an account