James Bachini

How To Clone Safemoon

Safemoon Clone Tutorial

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.

  1. How To Clone Safemoon [Video]
  2. Copy The Code
  3. Editing Name & Supply
  4. Deploy To BSC
  5. Token Tests

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]

James On YouTube

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:

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.

How To Clone Safemoon Using Remix
A helpful guide to finding your way around Remix

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

How To Compile Safemoon Token

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.

Deploy Safemoon Contract

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.

Verify and publish contract source code on BSCscan

We can also setup a liquidity pool on pancake swap.

Add Liquidity to Pancake Swap

We now have a token and liquidity pool setup and ready to go. Thanks to Derrick from Bizarre Brilliance for the inspiration.

Get The Blockchain Sector Newsletter, binge the YouTube channel and connect with me on Twitter

The Blockchain Sector newsletter goes out a few times a month when there is breaking news or interesting developments to discuss. All the content I produce is free, if you’d like to help please share this content on social media.

Thank you.

James Bachini

Disclaimer: Not a financial advisor, not financial advice. The content I create is to document my journey and for educational and entertainment purposes only. It is not under any circumstances investment advice. I am not an investment or trading professional and am learning myself while still making plenty of mistakes along the way. Any code published is experimental and not production ready to be used for financial transactions. Do your own research and do not play with funds you do not want to lose.