Giter Site home page Giter Site logo

smart-contract-token-sale's Introduction

BlockFood Token Sale Smart Contract

Goal

The goal of this smart contract is to create and distribute BlockFoodToken according to the rules specified in the whitepaper.

The token sale behaviour is coded into the smart contract itself. Nothing is hidden.

Usage

The BlockFood Token Sale Smart Contract will be deployed on the Ethereum blockchain before the date of the token sale.

Its address will be communicated from the https://blockfood.io website.

Dev

The smart contract has been written in test-driven development using the Truffle framework.

Prerequisite

  • Node.js 8+

  • Truffle 4.0.1+

npm i -g truffle

Launch tests

In a console, from the base directory of the project, type:

truffle test

This will output something like this:

$ truffle test
Compiling .\contracts\BlockFoodToken.sol...
Compiling .\contracts\ERC20Token.sol...
Compiling .\contracts\Migrations.sol...
Deployer {
  chain:
   DeferredChain {
     _accept: [Function],
     _reject: [Function],
     chain: Promise { <pending> },
     _done: [Function],
     _error: [Function],
     await: Promise { <pending> },
     started: false },
  logger: { log: [Function: log] },
  known_contracts: {},
  network: 'test',
  network_id: 4447,
  provider: { send: [Function: send], sendAsync: [Function: sendAsync] },
  basePath: 'C:\\Dev\\perso\\smart-contract-token-sale\\migrations' }
Deploy BlockFoodToken { target: '0xa3d736079d6bf7c14a96ab3ad131c349ceaf141e',
  phase1Date: 1515427200,
  phase2Date: 1516032000,
  phase3Date: 1516636800,
  phase4Date: 1517241600,
  endDate: 1518451200,
  phase1Rate: 1200,
  phase2Rate: 1100,
  phase3Rate: 1050,
  phase4Rate: 1000,
  minCap: 1000,
  maxCap: 54000 }


  Contract: BlockFoodToken
    √ should properly set the values from the constructor (281ms)
    buy
      √ should work (147ms)
      √ should throw if before token sale (114ms)
      √ should throw if after token sale (117ms)
      √ should throw if max cap reached (149ms)
      √ should give the right amount of BFC during phase 1 (621ms)
      √ should give the right amount of BFC during phase 2 (668ms)
      √ should give the right amount of BFC during phase 3 (620ms)
      √ should give the right amount of BFC during phase 4 (578ms)
    finalize
      √ should not be able to be called twice (153ms)
      √ should be callable only by the owner of the smart contract (121ms)
      √ should throw if endDate is not reached (107ms)
      √ should work if endDate or maxCap is reached and not set isCancelled to true (207ms)
      √ should transfer the funds to target if endDate or maxCap is reached (182ms)
      √ should mint the right amount of bfc for the OSE foundation (172ms)
      √ should set isCancelled to true if minCap not reached and not transfer ethereums to target (160ms)
    refund
      √ should throw if not cancelled (200ms)
WARNING FOR FURTHER TEST, TIME IS NOW 15 SECONDS LATER
      √ should send the ether back if cancelled (715ms)
    erc20 token capabilities
      balanceOf
        √ should return the balance of the account (230ms)
      totalSupply
        √ should return the total supply generated by the token sale (200ms)
      transfer
        √ should transfer BFC from sender to target  (307ms)
        √ should transfer BFC from sender to target only if amount available (307ms)
        √ should send Transfer event (209ms)
      approve
        √ should approve spending and send an Approval event (213ms)
      transferFrom
        √ should actually transfer approved transaction (264ms)
        √ should do nothing if transaction not approved (231ms)


  26 passing (7s)

smart-contract-token-sale's People

Contributors

conradle avatar

Watchers

 avatar  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.