Distribution of your coin (part 2)
By: Zanno Jacklin
Tags: Smart Contracts, Cryptocurrency, Crowdsale, Ethereum, Binance Smart Chain

So you’ve made your own cryptocurrency and created a faucet that gives a small amount of currency to anyone who claims it. Let’s give people an opportunity to buy larger quantities of your coin.

Can’t read the full article? Become a member of Medium here

There are many ways to let others purchase your coin, the easiest way is to simply put it up for sale at a DEX such as PancakeSwap. The downside with using a DEX service is that you have to put in as much liquidity as the total sum of all the coins you wish to sell.

For example, lets assume you wish to sell 10 000 of your coins and you set the price at 0.001 BNB per coin. You will have to list the 10 000 of your coins together with 10 000 x 0.001 BNB in order to activate trading. That means you have to lock 10 BNB (roughly $5500 USD at the time of writing this), and you might not have that amount of money at the time.

Instead you can write a smart contract which allows people to purchase your coin directly from the contract itself. Contracts like these are often called crowdsale contract or selfdrop contract.

I’m not going to write all of the code here, but you can find it at github: https://github.com/Creepybits/BEP-20-contracts/blob/Master/selfdrop.sol

Open Remix and create a new file called selfdrop.sol. Copy the code from github, paste it in Remix and compile.

At the deploy screen chose “injected web3”, rate (price of the coin), wallet (the address of the wallet that you wish the BNB/ETH recieved from the sale should be sent to) and the contract address of your coin. Also make sure that the contract you are deploying is the correct one.

When you are happy with the settings, press “transact” and confirm in Metamask. You will get some confirmation info at the bottom of the screen. Copy the hash and paste it in the blockchain explorer you used to deploy the contract.

When you check your contract and wish to verify it, as explained in previous posts, you will get a message saying that you need to change the constructor values.

The correct numbers will be found when you check the transaction of the deployment of the contract. Copy those numbers and replace the ones in the verifyingprocess.

After this there shouldn’t be a problem to verify the contract.

Now you have to transfer the coins you wish to sell to the contract. I sent 10 000 ZannoMoney that I wish to sell to the contract.

Next up we will try to buy some coins by sending BNB to the contract.

I sent 0.1 BNB from another address that I use for testing, and the contract sent me back 1000 ZannoMoney (ZMO) as well as forwarding the 0.1 BNB to the address I specified when deploying the contract.

The “Rate” you put in when deploying the contract decides at which price people can buy your coin. A rate of 10000 means that one of your coin will cost 0.0001 BNB (or ETH if you deploy it at Ethereum blockchain).

Now you have created a cryptocurremcy of your own, written a faucet contract as a way of distribution and finally written a contract for crowdselling your coin.

I hope you have enjoyed these guides!