Blockwell

PCHAIN

ERC20

This contract is an ERC20 token.

Name PCHAIN
Symbol PAI
Decimals 18
Total Supply 2,100,000,000 PAI

About

Stats

Public Functions 13
Event Types 9
Code Size 10,636 bytes

Events (9) keyboard_arrow_up

Approval Event

Parameters help
_owner
address help
_spender
address help
_value
uint256 help

BlacklistEvent Event

Parameters help
_addr
address help
_b
uint256 help

CloseBlacklistSwitchEvent Event

Parameters help
_b
bool help

EthSweepSuccess Event

Parameters help
_addr
address help
_value
uint256 help

PurchaseSuccess Event

Parameters help
_addr
address help
_weiAmount
uint256 help
_crowdsaleEth
uint256 help
_balance
uint256 help

ReflectEvent Event

Parameters help
_addr
address help
_paiAddr
string help

SetReflectSwitchEvent Event

Parameters help
_b
bool help

SetTransferLockEvent Event

Parameters help
_b
bool help

Transfer Event

Parameters help
_from
address help
_to
address help
_value
uint256 help

name Variable

string help

decimals Variable

uint256 help

symbol Variable

string help

wallet Variable

address help

start Variable

uint help

end Variable

uint help

deadline Variable

uint help

teamShare Variable

uint256 help

foundationShare Variable

uint256 help

posShare Variable

uint256 help

saleShare Variable

uint256 help

crowdETHTotal Variable

uint256 help

crowdPrice Variable

uint256 help

crowdTarget Variable

uint256 help

reflectSwitch Variable

bool help

blacklistSwitch Variable

bool help

totalSupply Variable

uint256 help

owner Variable

address help

crowdETHs Variable

mapping(address => uint256) help

reflects Variable

mapping(address => string) help

saleAddr Variable

address help
Internal Variable

transferLock Variable

bool help
Internal Variable

balances Variable

mapping(address => uint256) help
Internal Variable

allowed 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

Modifiers help

onlyOwner checks for the following:
Source Code
function transferOwnership(address _newOwner) onlyOwner {
  if (_newOwner != address(0)) {
    owner = _newOwner;
  }
}

Parameters help

Name Type
_owner
address help

Properties

Visibility help public
Mutability help constant
Source Code
function balanceOf(address _owner) constant returns (uint256 balance) {
  return balances[_owner];
}

Parameters help

Name Type
_to
address help
_value
uint256 help

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyPayloadSize checks for the following:
canTransfer checks for the following:
Source Code
function transfer(address _to, uint256 _value)
  onlyPayloadSize(2 * 32)
  canTransfer
  returns (bool success)
{
  balances[msg.sender] = safeSub(balances[msg.sender], _value);
  balances[_to] = safeAdd(balances[_to], _value);
  Transfer(msg.sender, _to, _value);
  return true;
}

Parameters help

Name Type
_from
address help
_to
address help
_value
uint256 help

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyPayloadSize checks for the following:
canTransfer checks for the following:
Source Code
function transferFrom(
  address _from,
  address _to,
  uint256 _value
) onlyPayloadSize(3 * 32) canTransfer returns (bool success) {
  uint256 _allowance = allowed[_from][msg.sender];
  allowed[_from][msg.sender] = safeSub(_allowance, _value);
  balances[_from] = safeSub(balances[_from], _value);
  balances[_to] = safeAdd(balances[_to], _value);
  Transfer(_from, _to, _value);
  return true;
}

Parameters help

Name Type
_spender
address help
_value
uint256 help

Properties

Visibility help public
Mutability help transaction

Modifiers help

canTransfer checks for the following:
Source Code
function approve(address _spender, uint256 _value)
  canTransfer
  returns (bool success)
{
  // To change the approve amount you first have to reduce the addresses`
  //  allowance to zero by calling `approve(_spender, 0)` if it is not
  //  already 0 to mitigate the race condition described here:
  //  https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
  if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) revert();

  allowed[msg.sender][_spender] = _value;
  Approval(msg.sender, _spender, _value);
  return true;
}

Parameters help

Name Type
_owner
address help
_spender
address help

Properties

Visibility help public
Mutability help constant
Source Code
function allowance(address _owner, address _spender)
  constant
  returns (uint256 remaining)
{
  return allowed[_owner][_spender];
}

setTransferLock keyboard_arrow_up

Parameters help

Name Type
_lock
bool help

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyOwner checks for the following:
Source Code
function setTransferLock(bool _lock) onlyOwner {
  transferLock = _lock;
  SetTransferLockEvent(_lock);
}

closeBlacklistSwitch keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyOwner checks for the following:
Source Code
function closeBlacklistSwitch() onlyOwner {
  blacklistSwitch = false;
  CloseBlacklistSwitchEvent(false);
}

setBlacklist keyboard_arrow_up

Parameters help

Name Type
_addr
address help

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyOwner checks for the following:

Requirements help

Source Code
function setBlacklist(address _addr) onlyOwner {
  require(blacklistSwitch);
  uint256 tokenAmount = balances[_addr]; //calculate user token amount
  balances[_addr] = 0; //clear user‘s PAI balance
  balances[saleAddr] = safeAdd(balances[saleAddr], tokenAmount); //add PAI tokenAmount to Sale
  Transfer(_addr, saleAddr, tokenAmount);
  BlacklistEvent(_addr, tokenAmount);
}

setReflectSwitch keyboard_arrow_up

Parameters help

Name Type
_s
bool help

Properties

Visibility help public
Mutability help transaction

Modifiers help

onlyOwner checks for the following:
Source Code
function setReflectSwitch(bool _s) onlyOwner {
  reflectSwitch = _s;
  SetReflectSwitchEvent(_s);
}

reflect keyboard_arrow_up

Parameters help

Name Type
_paiAddress
string help

Properties

Visibility help public
Mutability help transaction

Requirements help

Source Code
function reflect(string _paiAddress) {
  require(reflectSwitch);
  reflects[msg.sender] = _paiAddress;
  ReflectEvent(msg.sender, _paiAddress);
}

purchase keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help payable
Source Code
function purchase() payable {
  require(block.timestamp <= deadline); //the timestamp must be less than the deadline time
  require(tx.gasprice <= 60000000000);
  require(block.timestamp >= start); //the timestamp must be greater than the start time
  uint256 weiAmount = msg.value; // The amount purchased by the current user
  require(weiAmount >= 0.1 ether);
  crowdETHTotal = safeAdd(crowdETHTotal, weiAmount); // Calculate the total amount purchased by all users
  require(crowdETHTotal <= crowdTarget); // The total amount is less than or equal to the target amount
  uint256 userETHTotal = safeAdd(crowdETHs[msg.sender], weiAmount); // Calculate the total amount purchased by the current user
  if (block.timestamp <= end) {
    // whether the current timestamp is in the first phase
    require(userETHTotal <= 0.4 ether); // whether the total amount purchased by the current user is less than 0.4ETH
  } else {
    require(userETHTotal <= 10 ether); // whether the total amount purchased by the current user is less than 10ETH
  }

  crowdETHs[msg.sender] = userETHTotal; // Record the total amount purchased by the current user

  uint256 tokenAmount = safeMul(weiAmount, crowdPrice); //calculate user token amount
  balances[msg.sender] = safeAdd(tokenAmount, balances[msg.sender]); //recharge user‘s PAI balance
  balances[saleAddr] = safeSub(balances[saleAddr], tokenAmount); //sub PAI tokenAmount from  Sale
  wallet.transfer(weiAmount);
  Transfer(saleAddr, msg.sender, tokenAmount);
  PurchaseSuccess(msg.sender, weiAmount, crowdETHs[msg.sender], tokenAmount);
}

constructor keyboard_arrow_up

Parameters help

This function has no parameters.

Properties

Visibility help public
Mutability help payable
Source Code
function() payable {
  purchase();
}

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 SafeMath.safeMul keyboard_arrow_up

Parameters help

Name Type
a
uint256 help
b
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function safeMul(uint256 a, uint256 b) internal returns (uint256) {
  uint256 c = a * b;
  assert(a == 0 || c / a == b);
  return c;
}

internal SafeMath.safeDiv keyboard_arrow_up

Parameters help

Name Type
a
uint256 help
b
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function safeDiv(uint256 a, uint256 b) internal returns (uint256) {
  assert(b > 0);
  uint256 c = a / b;
  assert(a == b * c + (a % b));
  return c;
}

internal SafeMath.safeSub keyboard_arrow_up

Parameters help

Name Type
a
uint256 help
b
uint256 help

Properties

Visibility help internal
Mutability help transaction

Requirements help

Source Code
function safeSub(uint256 a, uint256 b) internal returns (uint256) {
  assert(b <= a);
  return a - b;
}

internal SafeMath.safeAdd keyboard_arrow_up

Parameters help

Name Type
a
uint256 help
b
uint256 help

Properties

Visibility help internal
Mutability help transaction
Source Code
function safeAdd(uint256 a, uint256 b) internal returns (uint256) {
  uint256 c = a + b;
  assert(c >= a && c >= b);
  return c;
}

internal SafeMath.assert keyboard_arrow_up

Parameters help

Name Type
assertion
bool help

Properties

Visibility help internal
Mutability help transaction
Source Code
function assert(bool assertion) internal {
  if (!assertion) {
    revert();
  }
}