Blockwell

TrueFi

ERC20

This contract is an ERC20 token.

Name TrueFi
Symbol TRU
Decimals 8
Total Supply 1,441,129,427 TRU

About link

TrueFi (TRU) is a cryptocurrency and operates on the Ethereum platform. TrueFi has a current supply of 1,446,312,655 with 140,608,485 in circulation. The last known price of TrueFi is 0.1507301 USD and is up 8.20 over the last 24 hours. It is currently trading on 16 active market(s) with $3,833,276.19 traded over the last 24 hours. More information can be found at https://truefi.io/.

Stats

Public Functions 27
Event Types 3
Code Size 49,309 bytes

Library Use

Uses SafeMath for uint256.

Events (3) keyboard_arrow_up

Approval Event

Parameters help
owner
address help
spender
address help
value
uint256 help

OwnershipTransferred Event

Parameters help
previousOwner
address help
newOwner
address help

Transfer Event

Parameters help
from
address help
to
address help
value
uint256 help

MAX_SUPPLY Constant

uint256 help
145000000000000000

LOCK_START Constant

uint256 help
1595609911

FIRST_EPOCH_DELAY Constant

uint256 help
30 days

EPOCH_DURATION Constant

uint256 help
90 days

TOTAL_EPOCHS Constant

uint256 help
8

timeLockRegistry Variable

address help

returnsLocked Variable

bool help

totalSupply Variable

uint256 help

balanceOf Variable

mapping(address => uint256) help

distribution Variable

mapping(address => uint256) help
Internal Variable

initalized Variable

bool help
Internal Variable

allowance Variable

mapping(address => mapping(address => uint256)) help
Internal Variable

attributes Variable

mapping(uint144 => uint256) help
Internal Variable

owner_ Variable

address help
Internal Variable

pendingOwner_ Variable

address help
Internal Variable

Functions Expand All Collapse All

owner keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function owner() public view returns (address) {
  return owner_;
}

pendingOwner keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function pendingOwner() public view returns (address) {
  return pendingOwner_;
}

transferOwnership keyboard_arrow_up

Parameters help

Name Type
newOwner
address help

Properties

Visibility help public
Mutability help transaction
Source Code
function transferOwnership(address newOwner) public onlyOwner {
  pendingOwner_ = newOwner;
}

claimOwnership keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction
Source Code
function claimOwnership() public onlyPendingOwner {
  address _pendingOwner = pendingOwner_;
  emit OwnershipTransferred(owner_, _pendingOwner);
  owner_ = _pendingOwner;
  pendingOwner_ = address(0);
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help pure
Source Code
function name() public pure override returns (string memory) {
  return "TrustToken";
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help pure
Source Code
function symbol() public pure override returns (string memory) {
  return "TRU";
}

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help pure
Source Code
function decimals() public pure override returns (uint8) {
  return 8;
}

Parameters help

Name Type
recipient
address help
amount
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function transfer(address recipient, uint256 amount)
  public
  virtual
  returns (bool)
{
  _transfer(_msgSender(), recipient, amount);
  return true;
}

Parameters help

Name Type
spender
address help
amount
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function approve(address spender, uint256 amount)
  public
  virtual
  returns (bool)
{
  _approve(_msgSender(), spender, amount);
  return true;
}

Parameters help

Name Type
sender
address help
recipient
address help
amount
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function transferFrom(
  address sender,
  address recipient,
  uint256 amount
) public virtual returns (bool) {
  _transfer(sender, recipient, amount);
  _approve(
    sender,
    _msgSender(),
    allowance[sender][_msgSender()].sub(
      amount,
      "ERC20: transfer amount exceeds allowance"
    )
  );
  return true;
}

Parameters help

Name Type
spender
address help
addedValue
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function increaseAllowance(address spender, uint256 addedValue)
  public
  virtual
  returns (bool)
{
  _approve(
    _msgSender(),
    spender,
    allowance[_msgSender()][spender].add(addedValue)
  );
  return true;
}

Parameters help

Name Type
spender
address help
subtractedValue
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function decreaseAllowance(address spender, uint256 subtractedValue)
  public
  virtual
  returns (bool)
{
  _approve(
    _msgSender(),
    spender,
    allowance[_msgSender()][spender].sub(
      subtractedValue,
      "ERC20: decreased allowance below zero"
    )
  );
  return true;
}

setTimeLockRegistry keyboard_arrow_up

Parameters help

Name Type
newTimeLockRegistry
address help

Properties

Visibility help public
Mutability help transaction
Source Code
function setTimeLockRegistry(address newTimeLockRegistry) external onlyOwner {
  require(newTimeLockRegistry != address(0), "cannot be zero address");
  require(
    newTimeLockRegistry != timeLockRegistry,
    "must be new TimeLockRegistry"
  );
  timeLockRegistry = newTimeLockRegistry;
}

lockReturns keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction
Source Code
function lockReturns() external onlyOwner {
  returnsLocked = true;
}

registerLockup keyboard_arrow_up

Parameters help

Name Type
receiver
address help
amount
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function registerLockup(address receiver, uint256 amount)
  external
  onlyTimeLockRegistry
{
  require(balanceOf[msg.sender] >= amount, "insufficient balance");

  // add amount to locked distribution
  distribution[receiver] = distribution[receiver].add(amount);

  // transfer to recipient
  _transfer(msg.sender, receiver, amount);
}

lockedBalance keyboard_arrow_up

Parameters help

Name Type
account
address help

Properties

Visibility help public
Mutability help view
Source Code
function lockedBalance(address account) public view returns (uint256) {
  // distribution * (epochsLeft / totalEpochs)
  return distribution[account].mul(epochsLeft()).div(TOTAL_EPOCHS);
}

unlockedBalance keyboard_arrow_up

Parameters help

Name Type
account
address help

Properties

Visibility help public
Mutability help view
Source Code
function unlockedBalance(address account) public view returns (uint256) {
  // totalBalance - lockedBalance
  return balanceOf[account].sub(lockedBalance(account));
}

epochsPassed keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function epochsPassed() public view returns (uint256) {
  // return 0 if timestamp is lower than start time
  if (block.timestamp < LOCK_START) {
    return 0;
  }

  // how long it has been since the beginning of lockup period
  uint256 timePassed = block.timestamp.sub(LOCK_START);

  // 1st epoch is FIRST_EPOCH_DELAY longer; we check to prevent subtraction underflow
  if (timePassed < FIRST_EPOCH_DELAY) {
    return 0;
  }

  // subtract the FIRST_EPOCH_DELAY, so that we can count all epochs as lasting EPOCH_DURATION
  uint256 totalEpochsPassed = timePassed.sub(FIRST_EPOCH_DELAY).div(
    EPOCH_DURATION
  );

  // epochs don't count over TOTAL_EPOCHS
  if (totalEpochsPassed > TOTAL_EPOCHS) {
    return TOTAL_EPOCHS;
  }

  return totalEpochsPassed;
}

epochsLeft keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function epochsLeft() public view returns (uint256) {
  return TOTAL_EPOCHS.sub(epochsPassed());
}

nextEpoch keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function nextEpoch() public view returns (uint256) {
  // get number of epochs passed
  uint256 passed = epochsPassed();

  // if all epochs passed, return
  if (passed == TOTAL_EPOCHS) {
    // return INT_MAX
    return uint256(-1);
  }

  // if no epochs passed, return latest epoch + delay + standard duration
  if (passed == 0) {
    return latestEpoch().add(FIRST_EPOCH_DELAY).add(EPOCH_DURATION);
  }

  // otherwise return latest epoch + epoch duration
  return latestEpoch().add(EPOCH_DURATION);
}

latestEpoch keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help view
Source Code
function latestEpoch() public view returns (uint256) {
  // get number of epochs passed
  uint256 passed = epochsPassed();

  // if no epochs passed, return lock start time
  if (passed == 0) {
    return LOCK_START;
  }

  // accounts for first epoch being longer
  // lockStart + firstEpochDelay + (epochsPassed * epochDuration)
  return LOCK_START.add(FIRST_EPOCH_DELAY).add(passed.mul(EPOCH_DURATION));
}

finalEpoch keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help pure
Source Code
function finalEpoch() public pure returns (uint256) {
  // lockStart + firstEpochDelay + (epochDuration * totalEpochs)
  return
    LOCK_START.add(FIRST_EPOCH_DELAY).add(EPOCH_DURATION.mul(TOTAL_EPOCHS));
}

lockStart keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help pure
Source Code
function lockStart() public pure returns (uint256) {
  return LOCK_START;
}

initialize keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function initialize() public {
  require(!initalized, "already initialized");
  owner_ = msg.sender;
  initalized = true;
}

mint keyboard_arrow_up

Parameters help

Name Type
_to
address help
_amount
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function mint(address _to, uint256 _amount) external onlyOwner {
  if (totalSupply.add(_amount) <= MAX_SUPPLY) {
    _mint(_to, _amount);
  } else {
    revert("Max supply exceeded");
  }
}

burn keyboard_arrow_up

Parameters help

Name Type
amount
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function burn(uint256 amount) external {
  _burn(msg.sender, amount);
}

rounding keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help pure
Source Code
function rounding() public pure returns (uint8) {
  return 8;
}

Internal Functions Expand All Collapse All

Internal functions are parts of the contract that can't be used directly, but instead are used by the public functions listed above.

internal TimeLockedToken._transfer keyboard_arrow_up

Parameters help

Name Type
_from
address help
_to
address help
_value
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function _transfer(
  address _from,
  address _to,
  uint256 _value
) internal override {
  require(balanceOf[_from] >= _value, "insufficient balance");

  // transfers to owner proceed as normal when returns allowed
  if (!returnsLocked && _to == owner_) {
    transferToOwner(_from, _value);
    return;
  }
  // check if enough unlocked balance to transfer
  require(
    unlockedBalance(_from) >= _value,
    "attempting to transfer locked funds"
  );
  super._transfer(_from, _to, _value);
}

internal TimeLockedToken.transferToOwner keyboard_arrow_up

Parameters help

Name Type
_from
address help
_value
uint256 help

Properties

Visibility help internal
Mutability help transaction

Requirements help

Source Code
function transferToOwner(address _from, uint256 _value) internal {
  uint256 unlocked = unlockedBalance(_from);

  if (unlocked < _value) {
    // We want to have unlocked = value, i.e.
    // value = balance - distribution * epochsLeft / totalEpochs
    // distribution = (balance - value) * totalEpochs / epochsLeft
    distribution[_from] = balanceOf[_from].sub(_value).mul(TOTAL_EPOCHS).div(
      epochsLeft()
    );
  }
  super._transfer(_from, owner_, _value);
}

internal TimeLockedToken._burn keyboard_arrow_up

Parameters help

Name Type
_from
address help
_value
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function _burn(address _from, uint256 _value) internal override {
  require(balanceOf[_from] >= _value, "insufficient balance");
  require(unlockedBalance(_from) >= _value, "attempting to burn locked funds");

  super._burn(_from, _value);
}

internal ERC20._transfer keyboard_arrow_up

Parameters help

Name Type
sender
address help
recipient
address help
amount
uint256 help

Properties

Visibility help internal
Mutability help transaction

Requirements help

Source Code
function _transfer(
  address sender,
  address recipient,
  uint256 amount
) internal virtual {
  require(sender != address(0), "ERC20: transfer from the zero address");
  require(recipient != address(0), "ERC20: transfer to the zero address");

  _beforeTokenTransfer(sender, recipient, amount);

  balanceOf[sender] = balanceOf[sender].sub(
    amount,
    "ERC20: transfer amount exceeds balance"
  );
  balanceOf[recipient] = balanceOf[recipient].add(amount);
  emit Transfer(sender, recipient, amount);
}

internal ERC20._mint keyboard_arrow_up

Parameters help

Name Type
account
address help
amount
uint256 help

Properties

Visibility help internal
Mutability help transaction

Requirements help

Source Code
function _mint(address account, uint256 amount) internal virtual {
  require(account != address(0), "ERC20: mint to the zero address");

  _beforeTokenTransfer(address(0), account, amount);

  totalSupply = totalSupply.add(amount);
  balanceOf[account] = balanceOf[account].add(amount);
  emit Transfer(address(0), account, amount);
}

internal ERC20._burn keyboard_arrow_up

Parameters help

Name Type
account
address help
amount
uint256 help

Properties

Visibility help internal
Mutability help transaction

Requirements help

Source Code
function _burn(address account, uint256 amount) internal virtual {
  require(account != address(0), "ERC20: burn from the zero address");

  _beforeTokenTransfer(account, address(0), amount);

  balanceOf[account] = balanceOf[account].sub(
    amount,
    "ERC20: burn amount exceeds balance"
  );
  totalSupply = totalSupply.sub(amount);
  emit Transfer(account, address(0), amount);
}

internal ERC20._approve keyboard_arrow_up

Parameters help

Name Type
owner
address help
spender
address help
amount
uint256 help

Properties

Visibility help internal
Mutability help transaction

Requirements help

Source Code
function _approve(
  address owner,
  address spender,
  uint256 amount
) internal virtual {
  require(owner != address(0), "ERC20: approve from the zero address");
  require(spender != address(0), "ERC20: approve to the zero address");

  allowance[owner][spender] = amount;
  emit Approval(owner, spender, amount);
}

internal ERC20._beforeTokenTransfer keyboard_arrow_up

Parameters help

Name Type
from
address help
to
address help
amount
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function _beforeTokenTransfer(
  address from,
  address to,
  uint256 amount
) internal virtual {}

internal Context._msgSender keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help internal
Mutability help view
Source Code
function _msgSender() internal view virtual returns (address payable) {
  return msg.sender;
}

internal Context._msgData keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help internal
Mutability help view
Source Code
function _msgData() internal view virtual returns (bytes memory) {
  this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
  return msg.data;
}