An ICO contract for SpaceCoin
, an ERC20 token that implements a toggleable token transfer tax. The ICO aims to raise 30,000ETH through the sale of SpaceCoin over three phases:
Seed Phase
: 1.5k individual contribution max. 15k total.General Phase
: 1k indidivual contribution max. 30k total.Open Phase
: No individual contribution limits. 30k total.
- 500k max supply
- 2% toggable (default off) tx fee that goes to treasury.
- Run all tests using
npx hardhat test
- The contract is deployed on
Goerli Testnet
at0x3C681Ca14A58a054513786BF91b5C112684D50c1
and verified on etherscan.io. - My design is as follows:
- Two contracts
SpaceCoin
andSpaceCoinICO
, both of which are "Ownable" by an address provided in the ICO constructor. The ICO will instantiate a new instance of the token contract, at which point the entire supply is minted. 150k for the ICO contract, 350k for the treasury. SpaceCoin
extends to OZ'sERC20
contract and is kept as minimal as possible.- It overrides the ERC20
transfer()
function to allow for transfer tax collection (if active). - The manager of contract toggles the tax on or off.
- It uses default ERC20 values with 18 decimal places.
- It overrides the ERC20
SpaceCoinICO
encapsulates the rest of the features of the project.- Tokens are purchased through the
buyTokens()
function, which is either called directly or indirectly through thereceive()
, when investors directly send money to the contract. - All token sales are recorded in the
contributions
mapping, as well astokensToCollect
mapping. The latter is used for contributions that happen pre-Open phase. - Once ICO reaches Open phase, investors can use
redeemTokens()
to collect any tokens that have been purchased pre-Open phase. Investors who buy tokens in Open phase will automatically receive SPC. currentPhase
enum tracks the ICO progress, which can only be adjusted by the manager manually.- Whitelist feature implemented with the
whitelist
mapping. The manager can only add addresses to the whitelist.
- Tokens are purchased through the
- Two contracts
I've implemented a frontend using parcel
. On my system, the server instance is at http://localhost:5000.
cd frontend
npx parcel src/index.html --no-cache