Crypto Distribution – BEP20/ERC20 Sales Contract


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 purchase larger quantities of your coin.

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 of 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:

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.

Deploy Sales Contract

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.

constructor error

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.

correct code

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 CreepyCoin that I wish to sell to the contract.

Crypto CreepyCoin

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 CreepyCoin (CREEP) as well as forwarding the 0.1 BNB to the address I specified when deploying the contract.


Here we see the transaction. From is the purchasing address sending 0.1 BNB To the contract address. The contract address Transfer the 0.1 BNB to the wallet address specified in the contract. Lastly the contract sends 1,000 CREEP to the purchasing address.

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.

Promoted Exchanges

Note: Investing and trading with cryptocurrencies can result in significant loss

Binance and offer everything you need, along with a $20 welcome bonus.


BitPanda is the easiest cryptotrading platform, and perfect for the beginner.

ExpressVPN is the fastest and most secure on the market. Try it for FREE for 30 days!