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
State Variables (24) keyboard_arrow_up
Functions
transferOwnership keyboard_arrow_up
balanceOf keyboard_arrow_up
transfer keyboard_arrow_up
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;
}
transferFrom keyboard_arrow_up
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;
}
approve keyboard_arrow_up
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;
}
allowance keyboard_arrow_up
setTransferLock keyboard_arrow_up
closeBlacklistSwitch keyboard_arrow_up
setBlacklist keyboard_arrow_up
Modifiers help
onlyOwner checks for the following:
Requirements help
blacklistSwitch must be true
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
reflect keyboard_arrow_up
Requirements help
reflectSwitch must be true
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.
Requirements help
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);
}
Internal Functions
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
Requirements help
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
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
internal SafeMath.safeAdd keyboard_arrow_up
Source Code
function safeAdd(uint256 a, uint256 b) internal returns (uint256) {
uint256 c = a + b;
assert(c >= a && c >= b);
return c;
}