Code Monkey home page Code Monkey logo

solidity-initial-coin-offering's Introduction

my badge my badge my badge my badge my badge my badge

πŸ”– Solidity ICO Presale Smart Contract

This project demonstrates how to develop an ERC20 Token smart contract and its presale smart contract for an Initial Coin Offering deployed on BSC (but it's applicable for any Ethereum-based blockchain).

⚠ Disclaimer

This is a sample application with demonstration purpose only. Use it at your own risk.

πŸ“– How it works

Once both SC are deployed,Β anybody can buy tokens with BNB on TokenPresale.sol until presale ends. After presale finishes and owner transfers funds through transferTokens() and calls addLiquidityToPS() to add liquidity to PancakeSwap (is needed to add liquidity manually by the owner before this call?), anyone can buy and sell tokens on this DEX.

πŸ”§ How it must be deployed

The first SC that must be deployed is Token.sol.

TokenPresale.sol SC must be deployed (by passing ERC20 Token smart contract address in the constructor) right after Token.sol is deployed, otherwise any attacker may set the presale contract address by calling setPresaleContractAddress() from Token.sol. If you decide to deploy both SC at once, it is done automatically by Truffle, avoiding any risk.

πŸ“„ Token.sol

This smart contract allows to create and manage an ERC20 Token. It has the following features:

  • It can swap BNB for TKN.
  • It allows to burn tokens.
  • It is super deflationary, each transaction charges taxes. These taxes can be set individually for buying and/or selling transactions and transferred up to 4 different wallets.
  • It allows the owner to pause tokens transfers if necessary.
  • It is lockable to any custom date (at compiling time) to avoid rug pulls.

β„Ή NOTICE: Once it receives funds from the presale contract, call addLiquidityToPS() to add TKNs liquidity to PancakeSwap.

πŸ“„ TokenPresale.sol

This smart contract allows to manage the ICO for such ERC20 Token without intermediaries.

  • It is able to swap BNB for TKN during the presale.
  • Any user account should be whitelisted previously (if whitelist is enabled) in order to be able to buy tokens, unless this functionality is disabled.
  • User accounts may be added/removed to the whitelist with addToWhiteList(), addManyToWhitelist() and removeFromWhiteList() functions.
  • Any whitelisted user may exchange his BNBs for tokens with buyTokens() function.
  • It allows the owner to pause buyTokens() function if necessary.
  • Once the presale ends, it allows to transfer funds to the owner, then the owner should send BNBs and TKNs to PancakeSwap through addLiquidityToPS() function.
  • Once token funds are transferred to the owner, tokens are locked for X days.

solidity-initial-coin-offering's People

Contributors

robidity avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.