Whitelisted crowdsale

I want to know how to make a simple whitelist crowdsale contract for my existing erc20 token?

2 Likes

Hi @Md_Sejabur_Rahat . Since I just completed a project like this, I thought I would make a couple of high-level suggestions.

It seemed the best way was to extend the Openzeppelin Crowdsale contract(found here), and to have a separate contract for the whitelisting.

So if you create your own crowdsale contract, say, MyTokenSale, this can extend the Crowdsale.sol contract.

Additionally, if you create your own whitelisting contract, say, MyWhiteList, then MyTokenSale could import MyWhitelist in order to make sure buyers were whitelisted etc. before allowing a purchase.

Personally I used a number of simple functions in my white-listing contract to set / get / and query the whitelisted state of a particular address.

These states (booleans), were then simply stored in a mapping within the whitelist contract. And of course, whitelisting could only be performed by authorized parties, i.e. the owner of the contract, using Ownable for instance.

Hope that helps at all. Good luck.

p.s. You might notice that the Crowdsale.sol file is no longer available in the most current repo, the version above is from the openzeppelin-contracts v2.5.1, so it may have earlier compiler requirements to watch out for.

1 Like

Can you provide me a source code?

1 Like

Hi @Md_Sejabur_Rahat,

OpenZeppelin Contracts 2.5.1 includes a Whitelisted Crowdsale: https://docs.openzeppelin.com/contracts/2.x/api/crowdsale#WhitelistCrowdsale

1 Like