Blockwell

Cajutel

ERC20

This contract is an ERC20 token.

Name Cajutel
Symbol CAJ
Decimals 18
Total Supply 1,780,000 CAJ

About link description

Cajutel (CAJ) is a cryptocurrency and operates on the Ethereum platform. Cajutel has a current supply of 1,780,000 with 1,352,388.80828916 in circulation. The last known price of Cajutel is 0.91249457 USD and is up 0.79 over the last 24 hours. It is currently trading on 2 active market(s) with $0.00 traded over the last 24 hours. More information can be found at https://cajutel.io.

Stats

Public Functions 17
Event Types 5
Code Size 55,663 bytes

Events (5) keyboard_arrow_up

DividendClaimed Event

Parameters help
id
uint256 help
_address
address help
_claim
uint256 help

DividendRecycled Event

Parameters help
id
uint256 help
_recycler
address help
_blockNumber
uint256 help
_amount
uint256 help
_totalSupply
uint256 help

DividendTransfered Event

Parameters help
id
uint256 help
_address
address help
_block
uint256 help
_amount
uint256 help
_totalSupply
uint256 help

Transfer Event

Parameters help
from
address help
to
address help
value
uint256 help

UnclaimedDividendTransfer Event

Parameters help
id
uint256 help
_value
uint256 help

migrateAddress Variable

address help

icoSince Variable

uint256 help

icoTill Variable

uint256 help

collectedEthers Variable

uint256 help

owner Variable

address help

newOwner Variable

address help

standard Variable

string help

name Variable

string help

symbol Variable

string help

decimals Variable

uint8 help

totalSupply Variable

uint256 help

locked Variable

bool help

creationBlock Variable

uint256 help

balanceOf Variable

mapping(address => uint256) help

phases Variable

Phase[] help
Internal Variable

dividends Variable

Dividend[] help
Internal Variable

dividendsClaimed Variable

mapping(address => uint256) help
Internal Variable

loggedTotalSupply Variable

LogValueBlock[] help
Internal Variable

loggedBalances Variable

mapping(address => LogValueBlock[]) help
Internal Variable

allowance Variable

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

Functions Expand All Collapse All

transferOwnership keyboard_arrow_up

Parameters help

Name Type
_newOwner
address help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function transferOwnership(address _newOwner) public onlyOwner {
  require(_newOwner != address(0));
  newOwner = _newOwner;
}

acceptOwnership keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction
Source Code
function acceptOwnership() public {
  if (msg.sender == newOwner) {
    owner = newOwner;
  }
}

Parameters help

Name Type
_to
address help
_value
uint256 help

Properties

Visibility help public
Mutability help transaction

Modifiers help

Requirements help

Source Code
function transfer(address _to, uint256 _value) public onlyPayloadSize(2) {
  require(locked == false);

  bool status = transferInternal(msg.sender, _to, _value);

  require(status == true);
}

Parameters help

Name Type
_spender
address help
_value
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function approve(address _spender, uint256 _value)
  public
  returns (bool success)
{
  if (locked) {
    return false;
  }

  allowance[msg.sender][_spender] = _value;

  return true;
}

Parameters help

Name Type
_from
address help
_to
address help
_value
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function transferFrom(
  address _from,
  address _to,
  uint256 _value
) public returns (bool success) {
  if (locked) {
    return false;
  }

  if (allowance[_from][msg.sender] < _value) {
    return false;
  }

  bool _success = transferInternal(_from, _to, _value);

  if (_success) {
    allowance[_from][msg.sender] -= _value;
  }

  return _success;
}

addDividend keyboard_arrow_up

Parameters help

Name Type
recycleTime
uint256 help

Properties

Visibility help public
Mutability help payable

Requirements help

Source Code
function addDividend(uint256 recycleTime) public payable onlyOwner {
  require(msg.value > 0);

  uint256 id = dividends.length;
  uint256 _totalSupply = totalSupply;

  dividends.push(
    Dividend(
      id,
      block.number,
      now,
      msg.value,
      0,
      0,
      _totalSupply,
      recycleTime,
      false
    )
  );

  DividendTransfered(id, msg.sender, block.number, msg.value, _totalSupply);
}

claimDividend keyboard_arrow_up

Parameters help

Name Type
dividendId
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function claimDividend(uint256 dividendId) public returns (bool) {
  if ((dividends.length).sub(1) < dividendId) {
    return false;
  }

  Dividend storage dividend = dividends[dividendId];

  if (dividend.claimed[msg.sender] == true) {
    return false;
  }

  if (dividend.recycled == true) {
    return false;
  }

  if (now >= dividend.time.add(dividend.recycleTime)) {
    return false;
  }

  uint256 balance = valueAt(loggedBalances[msg.sender], dividend.block);

  if (balance == 0) {
    return false;
  }

  uint256 claim = balance.mul(dividend.amount).div(dividend.totalSupply);

  dividend.claimed[msg.sender] = true;

  dividend.claimedAmount = dividend.claimedAmount.add(claim);

  if (claim > 0) {
    msg.sender.transfer(claim);
    DividendClaimed(dividendId, msg.sender, claim);

    return true;
  }

  return false;
}

claimDividends keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction
Source Code
function claimDividends() public {
  require(dividendsClaimed[msg.sender] < dividends.length);
  for (uint256 i = dividendsClaimed[msg.sender]; i < dividends.length; i++) {
    if (
      (dividends[i].claimed[msg.sender] == false) &&
      (dividends[i].recycled == false)
    ) {
      dividendsClaimed[msg.sender] = i.add(1);
      claimDividend(i);
    }
  }
}

recycleDividend keyboard_arrow_up

Parameters help

Name Type
dividendId
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function recycleDividend(uint256 dividendId)
  public
  onlyOwner
  returns (bool success)
{
  if (dividends.length.sub(1) < dividendId) {
    return false;
  }

  Dividend storage dividend = dividends[dividendId];

  if (dividend.recycled) {
    return false;
  }

  dividend.recycled = true;

  return true;
}

refundUnclaimedEthers keyboard_arrow_up

Parameters help

Name Type
dividendId
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function refundUnclaimedEthers(uint256 dividendId)
  public
  onlyOwner
  returns (bool success)
{
  if ((dividends.length).sub(1) < dividendId) {
    return false;
  }

  Dividend storage dividend = dividends[dividendId];

  if (dividend.recycled == false) {
    if (now < (dividend.time).add(dividend.recycleTime)) {
      return false;
    }
  }

  uint256 claimedBackAmount = (dividend.amount).sub(dividend.claimedAmount);

  dividend.transferedBack = claimedBackAmount;

  if (claimedBackAmount > 0) {
    owner.transfer(claimedBackAmount);

    UnclaimedDividendTransfer(dividendId, claimedBackAmount);

    return true;
  }

  return false;
}

constructor keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help payable

Requirements help

Source Code
function() public payable {
  bool status = buy(msg.sender, now, msg.value);

  require(status == true);
}

getIcoTokensAmount keyboard_arrow_up

Parameters help

Name Type
_collectedEthers
uint256 help
value
uint256 help

Properties

Visibility help public
Mutability help constant
Source Code
function getIcoTokensAmount(uint256 _collectedEthers, uint256 value)
  public
  constant
  returns (uint256)
{
  uint256 amount;

  uint256 newCollectedEthers = _collectedEthers;
  uint256 remainingValue = value;

  for (uint256 i = 0; i < phases.length; i++) {
    Phase storage phase = phases[i];

    if (phase.maxAmount > newCollectedEthers) {
      if (newCollectedEthers.add(remainingValue) > phase.maxAmount) {
        uint256 diff = phase.maxAmount.sub(newCollectedEthers);

        amount = amount.add(diff.mul(1 ether).div(phase.price));

        remainingValue = remainingValue.sub(diff);
        newCollectedEthers = newCollectedEthers.add(diff);
      } else {
        amount += (remainingValue * 1 ether) / phase.price;

        newCollectedEthers += remainingValue;

        remainingValue = 0;
      }
    }

    if (remainingValue == 0) {
      break;
    }
  }

  if (remainingValue > 0) {
    return 0;
  }

  return amount;
}

setMigrateAddress keyboard_arrow_up

Parameters help

Name Type
_address
address help

Properties

Visibility help public
Mutability help transaction
Source Code
function setMigrateAddress(address _address) public onlyOwner {
  migrateAddress = _address;
}

transferEthers keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction
Source Code
function transferEthers() public onlyOwner {
  owner.transfer(this.balance);
}

setLocked keyboard_arrow_up

Parameters help

Name Type
_locked
bool help

Properties

Visibility help public
Mutability help transaction
Source Code
function setLocked(bool _locked) public onlyOwner {
  locked = _locked;
}

setIcoDates keyboard_arrow_up

Parameters help

Name Type
_icoSince
uint256 help
_icoTill
uint256 help

Properties

Visibility help public
Mutability help transaction
Source Code
function setIcoDates(uint256 _icoSince, uint256 _icoTill) public onlyOwner {
  icoSince = _icoSince;
  icoTill = _icoTill;
}

setMigratedBalance keyboard_arrow_up

Parameters help

Name Type
_holderAddress
address help
_value
uint256 help

Properties

Visibility help public
Mutability help transaction

Requirements help

UNKNOWN VALUE must be greater than or equal to 0
Source Code
function setMigratedBalance(address _holderAddress, uint256 _value)
  public
  onlyMigrate
{
  require(balanceOf[this].sub(_value) >= 0);
  setBalance(_holderAddress, _value);
  setBalance(this, balanceOf[this].sub(_value));
  Transfer(this, _holderAddress, _value);
}

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 PhaseICO.buy keyboard_arrow_up

Parameters help

Name Type
_address
address help
time
uint256 help
value
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function buy(
  address _address,
  uint256 time,
  uint256 value
) internal returns (bool) {
  if (locked == true) {
    return false;
  }

  if (time < icoSince || time > icoTill) {
    return false;
  }

  if (value == 0) {
    return false;
  }

  uint256 amount = getIcoTokensAmount(collectedEthers, value);

  if (amount == 0) {
    return false;
  }

  uint256 selfBalance = valueAt(loggedBalances[this], block.number);
  uint256 holderBalance = valueAt(loggedBalances[_address], block.number);

  if (selfBalance < amount) {
    return false;
  }

  setBalance(_address, holderBalance.add(amount));
  setBalance(this, selfBalance.sub(amount));

  collectedEthers = collectedEthers.add(value);

  Transfer(this, _address, amount);

  return true;
}

internal LoggedERC20.valueAt keyboard_arrow_up

Parameters help

Name Type
valueBlocks
LogValueBlock[] help
_block
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function valueAt(LogValueBlock[] storage valueBlocks, uint256 _block)
  internal
  returns (uint256)
{
  if (valueBlocks.length == 0) {
    return 0;
  }

  if (valueBlocks[0].block > _block) {
    return 0;
  }

  if (valueBlocks[valueBlocks.length.sub(1)].block <= _block) {
    return valueBlocks[valueBlocks.length.sub(1)].value;
  }

  uint256 first = 0;
  uint256 last = valueBlocks.length.sub(1);

  uint256 middle = (first.add(last).add(1)).div(2);

  while (last > first) {
    if (valueBlocks[middle].block <= _block) {
      first = middle;
    } else {
      last = middle.sub(1);
    }

    middle = (first.add(last).add(1)).div(2);
  }

  return valueBlocks[first].value;
}

internal LoggedERC20.setBalance keyboard_arrow_up

Parameters help

Name Type
_address
address help
value
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function setBalance(address _address, uint256 value) internal {
  loggedBalances[_address].push(LogValueBlock(value, block.number));

  balanceOf[_address] = value;
}

internal ERC20.setBalance keyboard_arrow_up

Parameters help

Name Type
holder
address help
amount
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function setBalance(address holder, uint256 amount) internal {
  balanceOf[holder] = amount;
}

internal ERC20.transferInternal 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 transferInternal(
  address _from,
  address _to,
  uint256 value
) internal returns (bool success) {
  if (value == 0) {
    return false;
  }

  if (balanceOf[_from] < value) {
    return false;
  }

  setBalance(_from, balanceOf[_from].sub(value));
  setBalance(_to, balanceOf[_to].add(value));

  Transfer(_from, _to, value);

  return true;
}