Search code examples
tokenblockchainsmartcontractssolana

How to sell custom spl-token for sol on my website without the use of a market/exchange


I have made a custom SPL token and minted it to a wallet. I have an X amount of this custom-token minted on my phantom wallet.

We have a website for the custom-token and we want to launch a presale on our website, user connects wallet and purchase directly from website (its a meme coin).

The process is (user connects wallet, user enters amount of custom-token to buy, sol transferred to our wallet, custom-token transferred from our wallet to user)

How do we go about this?

Do I have to make my own smart contract for this?

Can this be done via web3?


Solution

  • You need some sort of separate smart contract to do the transfers, since you need to have one instruction which moves the user's SOL and your tokens all at once. With just web3, you won't be able to guarantee these movements.

    You can look at a few options in the Solana Program Library: