Letsfair Token Contract
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
contracts first commit Jan 29, 2018
test first commit Jan 29, 2018
package.json first commit Jan 29, 2018
truffle-config.js first commit Jan 29, 2018



Letsfair Token (LTF)

LetsfairToken contract implements the ERC20 with the StandardToken functions. The token's creation is realize in a gradual and programmatic way, distributed proportionally over a predefined period, specified by SchedulableToken.

contract LetsfairToken is SchedulableToken {

  string public constant name = "Letsfair";
  string public constant symbol = "LTF";
  uint8 public constant decimals = 18;

  address _beneficiary = 0x627306090abaB3A6e1400e9345bC60c78a8BEf57;
  uint256 _maxSupply = 10 ** 27; // 1 billion with decimals
  uint256 _duration = 157788000; // ~5 years in seconds

  function LetsfairToken() SchedulableToken(_beneficiary, _maxSupply, _duration) public {}


The SchedulableToken provide a method to create tokens progressively, in a gradual and programed way, until a specified date and amount. To effectively create tokens, it is necessary for someone to periodically run the release() function in the contract.

For example: You want to create a total of 1000 tokens (maxSupply) spread over 2 years (duration). In this way, when calling the release() function, the number of tokens that are entitled at that moment will be added to the beneficiary's wallet. In this scenario, by running the release() function every day at the same time over 2 years, the beneficiary will receive 1.37 tokens (1000 / 364.25 * 2) everyday.

Setting up the environment

OpenZeppelin is a library for writing secure smart contracts in Solidity. The OpenZeppelin library is the main dependency of this project and will be automatically installed with the letsfair-token installation.

Download the letsfair-token repository and install via npm:

$ git clone https://github.com/letsfair/letsfair-token.git
$ cd letsfair-token
$ npm install

Install the Truffle, which is the most popular development framework for the Ethereum.

$ npm install -g truffle

Use ganache-cli as the blockchain node because it is fast and developer-friendly.

$ npm install -g ganache-cli

NOTE: If you want to actually create the contract on the Ethereum testnet or main net you would have to use Geth or Parity.

Deploy the contract

Open a new terminal tab and run:

$ ganache-cli

Now back to the terminal tab where you installed Truffle, run the commands:

$ truffle compile

Compiling ./contracts/LetsfairToken.sol...
Compiling ./contracts/Migrations.sol...
Compiling ./contracts/SchedulableToken.sol...
Compiling zeppelin-solidity/contracts/math/SafeMath.sol...
Compiling zeppelin-solidity/contracts/token/BasicToken.sol...
Compiling zeppelin-solidity/contracts/token/BurnableToken.sol...
Compiling zeppelin-solidity/contracts/token/ERC20.sol...
Compiling zeppelin-solidity/contracts/token/ERC20Basic.sol...
Compiling zeppelin-solidity/contracts/token/StandardToken.sol...
Writing artifacts to ./build/contracts
$ truffle migrate

Using network 'development'.
Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... 0x56c3e47859d14839de827663e90bf1f79f40245b023ad573d1c6ba7075ab855b
  Migrations: 0x8c15c2b5a0ab8e42b5b63424cb0f0686657f423c
Saving successful migration to network...
  ... 0xb689126537ca90f1245354fb0e406abf3d7a42e3b41f1b315549c16a85da7cf7
Saving artifacts...
Running migration: 2_deploy_contracts.js
  Deploying LetsfairToken...
  ... 0x03c1387718e3e7c3dce0766e2ce32a5aa43e3ab4c1f5a9bf465228e8c1f0d7f4
  LetsfairToken: 0x4b61726dc5d6a7f9872d68c55a2917f689d01abd
Saving successful migration to network...
  ... 0x38ead5a1e95e5ed5589128f977bdb53d17ef603a538c38ef1d903c82fd3fe269
Saving artifacts...

Yay! It worked.

Running tests

$ truffle test

Using network 'development'.
  Contract: SchedulableToken
    ✓ should release total amount after duration (169ms)
    ✓ cannot be released after completion (173ms)
    Fragmented releases
      ✓ should release the tokens to this checkpoint - 10/10 (1690ms)
    Fragmented releases with transfer
      ✓ should release the tokens to this checkpoint and transfer for another account - 10/10 (2311ms)
    Fragmented releases with burn
      ✓ should burn all tokens to this checkpoint - 10/10 (2308ms)
  5 passing (8s)


Code released under the MIT License.

Deployed contract information