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.
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.
The smart contract has been written in test-driven development using the Truffle framework.
-
Node.js 8+
-
Truffle 4.0.1+
npm i -g truffle
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)