In this tutorial I’ll show you how to clone Safemoon and create your own token on Binance Smart Chain. I’m going to do this without any development tools using only a web browser with the metamask plugin.
Safemoon is a cryptocurrency token with a function that taxes 10% of all transactions and redistributes 5% to the liquidity pool and 5% to all token holders.
How To Clone Safemoon [Video]
Copy The Code
The first thing we need to do is copy the code from the github repository. The safemoon file is conveniently stored in a single file with no dependencies. The raw github file is here:
https://raw.githubusercontent.com/safemoonprotocol/Safemoon.sol/main/Safemoon.sol
We can then go to https://remix.ethereum.org an online Solidity editor and create a new file called whatever.sol and paste the code in.
We now have the safemoon contract in our editor so let’s change some variables.
Editing Name & Supply
If you scroll down to line 718 you’ll see the line
uint256 private _tTotal = 1000000000 * 10**6 * 10**9;
This is the total supply of tokens which we may wish to change. Note that safemoon has 9 decimals so if we want a hundred tokens we would change it to:
uint256 private _tTotal = 100 * 10**9;
One hundred times 10 to the power of 9.
We also want to change the name and the ticker symbol which are on lines 722 and 723 respectively
string private _name = "My Cool Coin";
string private _symbol = "COOL";
Now let’s continue to deploying it to Binance Smart Chain.
Deploy To BSC
Let’s click the compile tab from the left menu. The first thing we need to do is backdate our compiler version to match the code which was written to run on 0.6.12
Then click compile and not much will happen except we have compiled code ready to deploy. If you make any changes to the code base you’ll need to recompile.
Next lets click the next tab down “Deploy & Run Transactions” from the left menu (Looks like an ethereum symbol).
Then change environment setting to “Injected Web3” which will pop up a metamask prompt.
If you don’t have metamask set up you can download it for your web browser here: https://metamask.io/ And add Binance Smart Chain as the network using https://chainlist.org/ (Search Binance and add Binance Smart Chain Mainnet)
Once you have metamask set up go back to Remix.
Change Contract to the bottom option Safemoon – contracts/Safemoon.sol
Click deploy and sign the transaction.
At time of writing it cost 0.03339566 BNB or just under $20 USD to deploy the contracts.
You’ll get a confirmation contract address which you can import into metamask to see your tokens.
Token Tests
You can now try sending and receiving tokens in metamask.
We can also verify our contract on BSCscan using the source code from remix. This will allow us to execute contract functions from BSCscan if we need to.
We can also setup a liquidity pool on pancake swap.
We now have a token and liquidity pool setup and ready to go. Thanks to Derrick from Bizarre Brilliance for the inspiration.