Address Contract Partially Verified
Address
0x9C64bbBF75a77Fd98c028BB1fd9e1d76730449f8
Balance
0 ETH
Nonce
1
Code Size
7372 bytes
Creator
0x3b994EdD...F665 at tx 0x828377c2...a84e9a
Indexed Transactions
0 (1 on-chain, 1.3% indexed)
Contract Bytecode
7372 bytes
0x608060405234801561001057600080fd5b50600436106101e55760003560e01c806370a082311161010f578063a31052e8116100a2578063c408689311610071578063c4086893146105b3578063dd62ed3e146105d9578063e6108fc914610607578063f83e9a2014610633576101e5565b8063a31052e81461050f578063a457c2d714610535578063a9059cbb14610561578063bb5f747b1461058d576101e5565b80638870985b116100de5780638870985b146104895780638dc73521146104af57806395d89b41146104d55780639e20749a146104dd576101e5565b806370a082311461040f5780637362d9c81461043557806382dc1ec41461045b5780638456cb5914610481576101e5565b806339509351116101875780634c5a628c116101565780634c5a628c146103cb5780635c975abb146103d35780636c4e5c86146103db5780636ef8d66d14610407576101e5565b806339509351146103435780633f4ba83a1461036f57806346fbf68e14610379578063476fe9191461039f576101e5565b806318160ddd116101c357806318160ddd146102df57806323b872dd146102e75780632ff2e9dc1461031d578063313ce56714610325576101e5565b806306fdde03146101ea578063095ea7b3146102675780630cb7eb4c146102a7575b600080fd5b6101f261063b565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561022c578181015183820152602001610214565b50505050905090810190601f1680156102595780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6102936004803603604081101561027d57600080fd5b506001600160a01b03813516906020013561065f565b604080519115158252519081900360200190f35b6102cd600480360360208110156102bd57600080fd5b50356001600160a01b031661068e565b60408051918252519081900360200190f35b6102cd6106c6565b610293600480360360608110156102fd57600080fd5b506001600160a01b038135811691602081013590911690604001356106cc565b6102cd6106f6565b61032d610706565b6040805160ff9092168252519081900360200190f35b6102936004803603604081101561035957600080fd5b506001600160a01b03813516906020013561070b565b61037761074e565b005b6102936004803603602081101561038f57600080fd5b50356001600160a01b0316610837565b610293600480360360408110156103b557600080fd5b506001600160a01b038135169060200135610850565b610377610924565b610293610936565b610293600480360360408110156103f157600080fd5b506001600160a01b03813516906020013561093f565b610377610a62565b6102cd6004803603602081101561042557600080fd5b50356001600160a01b0316610a72565b6103776004803603602081101561044b57600080fd5b50356001600160a01b0316610a8d565b6103776004803603602081101561047157600080fd5b50356001600160a01b0316610adf565b610377610b2e565b6102cd6004803603602081101561049f57600080fd5b50356001600160a01b0316610bf5565b610293600480360360208110156104c557600080fd5b50356001600160a01b0316610c88565b6101f2610d4d565b610293600480360360608110156104f357600080fd5b506001600160a01b038135169060208101359060400135610d6c565b6102936004803603602081101561052557600080fd5b50356001600160a01b0316610eeb565b6102936004803603604081101561054b57600080fd5b506001600160a01b038135169060200135610fd3565b6102936004803603604081101561057757600080fd5b506001600160a01b038135169060200135611021565b610293600480360360208110156105a357600080fd5b50356001600160a01b0316611044565b6102cd600480360360208110156105c957600080fd5b50356001600160a01b0316611057565b6102cd600480360360408110156105ef57600080fd5b506001600160a01b038135811691602001351661109d565b6102936004803603604081101561061d57600080fd5b506001600160a01b0381351690602001356110c8565b6102cd6111b6565b6040518060400160405280600881526020016726b7b1b0a1b7b4b760c11b81525081565b60008161067261066d6111bc565b610bf5565b101561067d57600080fd5b61068783836111c0565b9392505050565b60006001600160a01b0382166106a357600080fd5b506001600160a01b0381166000908152600760205260409020600101545b919050565b60025490565b6000816106d885610bf5565b10156106e357600080fd5b6106ee848484611218565b949350505050565b6b26737304a0fdf607fc00000081565b601281565b600061072e8261072261071c6111bc565b8661109d565b9063ffffffff61127116565b61073961066d6111bc565b101561074457600080fd5b61068783836112cb565b61075e6107596111bc565b610837565b6107995760405162461bcd60e51b8152600401808060200182810382526030815260200180611b076030913960400191505060405180910390fd5b60045460ff166107e7576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b6004805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa61081a6111bc565b604080516001600160a01b039092168252519081900360200190a1565b600061084a60038363ffffffff61132316565b92915050565b600061086261085d6111bc565b611044565b61089d5760405162461bcd60e51b8152600401808060200182810382526040815260200180611bea6040913960400191505060405180910390fd5b6001600160a01b0383166108b057600080fd5b428210156108bd57600080fd5b6001600160a01b038316600081815260076020908152604091829020600101805490869055825181815291820186905282519093927f014515183d12c0df4c26d74864371ebfe412e000f1f0a252af66950035ff42fe928290030190a25060019392505050565b61093461092f6111bc565b61138a565b565b60045460ff1690565b600061094c61085d6111bc565b6109875760405162461bcd60e51b8152600401808060200182810382526040815260200180611bea6040913960400191505060405180910390fd5b6001600160a01b03831661099a57600080fd5b600082116109a757600080fd5b6001600160a01b0383166000908152600760205260409020548211156109cc57600080fd5b6001600160a01b0383166000908152600760205260409020546109f5908363ffffffff6113d216565b6001600160a01b03841660008181526007602090815260409182902084815560010154825187815291820194909452808201939093525190917f44cebfefa4561bee5b61d675ccfd8dc9969fff9cc15e7a4eccccd62af94f9c11919081900360600190a250600192915050565b610934610a6d6111bc565b611414565b6001600160a01b031660009081526020819052604090205490565b610a9861085d6111bc565b610ad35760405162461bcd60e51b8152600401808060200182810382526040815260200180611bea6040913960400191505060405180910390fd5b610adc8161145c565b50565b610aea6107596111bc565b610b255760405162461bcd60e51b8152600401808060200182810382526030815260200180611b076030913960400191505060405180910390fd5b610adc816114a4565b610b396107596111bc565b610b745760405162461bcd60e51b8152600401808060200182810382526030815260200180611b076030913960400191505060405180910390fd5b60045460ff1615610bbf576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6004805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a25861081a6111bc565b6001600160a01b0381166000908152600760205260408120600101544210610c2757610c2082610a72565b90506106c1565b6001600160a01b038216600090815260076020526040902054610c4983610a72565b11610c56575060006106c1565b6001600160a01b03821660009081526007602052604090205461084a90610c7c84610a72565b9063ffffffff6113d216565b6000610c9561085d6111bc565b610cd05760405162461bcd60e51b8152600401808060200182810382526040815260200180611bea6040913960400191505060405180910390fd5b6001600160a01b038216610ce357600080fd5b6001600160a01b038216600081815260076020908152604080832083815560010183905580518381529182018390528181019290925290517f44cebfefa4561bee5b61d675ccfd8dc9969fff9cc15e7a4eccccd62af94f9c119181900360600190a2506001919050565b604051806040016040528060038152602001624d434360e81b81525081565b6000610d7961085d6111bc565b610db45760405162461bcd60e51b8152600401808060200182810382526040815260200180611bea6040913960400191505060405180910390fd5b6001600160a01b038416610dc757600080fd5b60008311610dd457600080fd5b82610dde85610bf5565b1015610de957600080fd5b42821015610df657600080fd5b6001600160a01b038416600081815260076020908152604091829020600101805490869055825181815291820186905282519093927f014515183d12c0df4c26d74864371ebfe412e000f1f0a252af66950035ff42fe928290030190a26001600160a01b038516600090815260076020526040902054610e7c908563ffffffff61127116565b6001600160a01b03861660008181526007602090815260409182902084815560010154825189815291820194909452808201939093525190917f44cebfefa4561bee5b61d675ccfd8dc9969fff9cc15e7a4eccccd62af94f9c11919081900360600190a2506001949350505050565b6000610ef861085d6111bc565b610f335760405162461bcd60e51b8152600401808060200182810382526040815260200180611bea6040913960400191505060405180910390fd5b6001600160a01b038216610f4657600080fd5b6001600160a01b038216600090815260076020526040902060010154610f6b57600080fd5b6001600160a01b038216600081815260076020908152604080832060010180549084905581518181529283019390935280519293927f014515183d12c0df4c26d74864371ebfe412e000f1f0a252af66950035ff42fe9281900390910190a250600192915050565b600080610fe7610fe16111bc565b8561109d565b90508083101561101757611001818463ffffffff6113d216565b61100c61066d6111bc565b101561101757600080fd5b6106ee84846114ec565b60008161102f61066d6111bc565b101561103a57600080fd5b6106878383611544565b600061084a60058363ffffffff61132316565b6001600160a01b0381166000908152600760205260408120600101544210611081575060006106c1565b506001600160a01b031660009081526007602052604090205490565b6001600160a01b03918216600090815260016020908152604080832093909416825291909152205490565b60006110d561085d6111bc565b6111105760405162461bcd60e51b8152600401808060200182810382526040815260200180611bea6040913960400191505060405180910390fd5b6001600160a01b03831661112357600080fd5b6000821161113057600080fd5b8161113a84610bf5565b101561114557600080fd5b6001600160a01b038316600090815260076020526040902060010154421061118d576006546001600160a01b0384166000908152600760205260409020429091016001909101555b6001600160a01b0383166000908152600760205260409020546109f5908363ffffffff61127116565b60065481565b3390565b60045460009060ff161561120e576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b610687838361159c565b60045460009060ff1615611266576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6106ee8484846115b9565b600082820183811015610687576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b60045460009060ff1615611319576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6106878383611646565b60006001600160a01b03821661136a5760405162461bcd60e51b8152600401808060200182810382526022815260200180611bc86022913960400191505060405180910390fd5b506001600160a01b03166000908152602091909152604090205460ff1690565b61139b60058263ffffffff61169a16565b6040516001600160a01b038216907f0a8eb35e5ca14b3d6f28e4abf2f128dbab231a58b56e89beb5d636115001e16590600090a250565b600061068783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250611701565b61142560038263ffffffff61169a16565b6040516001600160a01b038216907fcd265ebaf09df2871cc7bd4133404a235ba12eff2041bb89d9c714a2621c7c7e90600090a250565b61146d60058263ffffffff61179816565b6040516001600160a01b038216907f22380c05984257a1cb900161c713dd71d39e74820f1aea43bd3f1bdd2096129990600090a250565b6114b560038263ffffffff61179816565b6040516001600160a01b038216907f6719d08c1888103bea251a4ed56406bd0c3e69723c8a1686e017e7bbe159b6f890600090a250565b60045460009060ff161561153a576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6106878383611819565b60045460009060ff1615611592576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6106878383611887565b60006115b06115a96111bc565b848461189b565b50600192915050565b60006115c6848484611987565b61163c846115d26111bc565b61163785604051806060016040528060288152602001611ba0602891396001600160a01b038a166000908152600160205260408120906116106111bc565b6001600160a01b03168152602081019190915260400160002054919063ffffffff61170116565b61189b565b5060019392505050565b60006115b06116536111bc565b8461163785600160006116646111bc565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff61127116565b6116a48282611323565b6116df5760405162461bcd60e51b8152600401808060200182810382526021815260200180611b7f6021913960400191505060405180910390fd5b6001600160a01b0316600090815260209190915260409020805460ff19169055565b600081848411156117905760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561175557818101518382015260200161173d565b50505050905090810190601f1680156117825780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b6117a28282611323565b156117f4576040805162461bcd60e51b815260206004820152601f60248201527f526f6c65733a206163636f756e7420616c72656164792068617320726f6c6500604482015290519081900360640190fd5b6001600160a01b0316600090815260209190915260409020805460ff19166001179055565b60006115b06118266111bc565b8461163785604051806060016040528060258152602001611c7360259139600160006118506111bc565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff61170116565b60006115b06118946111bc565b8484611987565b6001600160a01b0383166118e05760405162461bcd60e51b8152600401808060200182810382526024815260200180611c4f6024913960400191505060405180910390fd5b6001600160a01b0382166119255760405162461bcd60e51b8152600401808060200182810382526022815260200180611b376022913960400191505060405180910390fd5b6001600160a01b03808416600081815260016020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166119cc5760405162461bcd60e51b8152600401808060200182810382526025815260200180611c2a6025913960400191505060405180910390fd5b6001600160a01b038216611a115760405162461bcd60e51b8152600401808060200182810382526023815260200180611ae46023913960400191505060405180910390fd5b611a5481604051806060016040528060268152602001611b59602691396001600160a01b038616600090815260208190526040902054919063ffffffff61170116565b6001600160a01b038085166000908152602081905260408082209390935590841681522054611a89908263ffffffff61127116565b6001600160a01b038084166000818152602081815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a350505056fe45524332303a207472616e7366657220746f20746865207a65726f2061646472657373506175736572526f6c653a2063616c6c657220646f6573206e6f742068617665207468652050617573657220726f6c6545524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e6365526f6c65733a206163636f756e7420646f6573206e6f74206861766520726f6c6545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e6365526f6c65733a206163636f756e7420697320746865207a65726f206164647265737357686974656c69737441646d696e526f6c653a2063616c6c657220646f6573206e6f742068617665207468652057686974656c69737441646d696e20726f6c6545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a723158206356e79ef97577727e22b08f640d8c7694b6af31bbe815519d758bbdc20fc85e64736f6c63430005110032
Verified Source Code Partial Match
Compiler: v0.5.17+commit.d19bba13
EVM: istanbul
Optimization: Yes (200 runs)
MocaCoin.sol 996 lines
// File: node_modules\@openzeppelin\contracts\GSN\Context.sol
pragma solidity ^0.5.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
contract Context {
// Empty internal constructor, to prevent people from mistakenly deploying
// an instance of this contract, which should be used via inheritance.
constructor () internal { }
// solhint-disable-previous-line no-empty-blocks
function _msgSender() internal view returns (address payable) {
return msg.sender;
}
function _msgData() internal view returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
// File: node_modules\@openzeppelin\contracts\token\ERC20\IERC20.sol
pragma solidity ^0.5.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// File: node_modules\@openzeppelin\contracts\math\SafeMath.sol
pragma solidity ^0.5.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*
* _Available since v2.4.0._
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*
* _Available since v2.4.0._
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
// File: node_modules\@openzeppelin\contracts\token\ERC20\ERC20.sol
pragma solidity ^0.5.0;
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20Mintable}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin guidelines: functions revert instead
* of returning `false` on failure. This behavior is nonetheless conventional
* and does not conflict with the expectations of ERC20 applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20};
*
* Requirements:
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for `sender`'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal {
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens.
*
* This is internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Destroys `amount` tokens from `account`.`amount` is then deducted
* from the caller's allowance.
*
* See {_burn} and {_approve}.
*/
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
}
// File: node_modules\@openzeppelin\contracts\access\Roles.sol
pragma solidity ^0.5.0;
/**
* @title Roles
* @dev Library for managing addresses assigned to a Role.
*/
library Roles {
struct Role {
mapping (address => bool) bearer;
}
/**
* @dev Give an account access to this role.
*/
function add(Role storage role, address account) internal {
require(!has(role, account), "Roles: account already has role");
role.bearer[account] = true;
}
/**
* @dev Remove an account's access to this role.
*/
function remove(Role storage role, address account) internal {
require(has(role, account), "Roles: account does not have role");
role.bearer[account] = false;
}
/**
* @dev Check if an account has this role.
* @return bool
*/
function has(Role storage role, address account) internal view returns (bool) {
require(account != address(0), "Roles: account is the zero address");
return role.bearer[account];
}
}
// File: node_modules\@openzeppelin\contracts\access\roles\PauserRole.sol
pragma solidity ^0.5.0;
contract PauserRole is Context {
using Roles for Roles.Role;
event PauserAdded(address indexed account);
event PauserRemoved(address indexed account);
Roles.Role private _pausers;
constructor () internal {
_addPauser(_msgSender());
}
modifier onlyPauser() {
require(isPauser(_msgSender()), "PauserRole: caller does not have the Pauser role");
_;
}
function isPauser(address account) public view returns (bool) {
return _pausers.has(account);
}
function addPauser(address account) public onlyPauser {
_addPauser(account);
}
function renouncePauser() public {
_removePauser(_msgSender());
}
function _addPauser(address account) internal {
_pausers.add(account);
emit PauserAdded(account);
}
function _removePauser(address account) internal {
_pausers.remove(account);
emit PauserRemoved(account);
}
}
// File: node_modules\@openzeppelin\contracts\lifecycle\Pausable.sol
pragma solidity ^0.5.0;
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
contract Pausable is Context, PauserRole {
/**
* @dev Emitted when the pause is triggered by a pauser (`account`).
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by a pauser (`account`).
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state. Assigns the Pauser role
* to the deployer.
*/
constructor () internal {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!_paused, "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(_paused, "Pausable: not paused");
_;
}
/**
* @dev Called by a pauser to pause, triggers stopped state.
*/
function pause() public onlyPauser whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Called by a pauser to unpause, returns to normal state.
*/
function unpause() public onlyPauser whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
// File: @openzeppelin\contracts\token\ERC20\ERC20Pausable.sol
pragma solidity ^0.5.0;
/**
* @title Pausable token
* @dev ERC20 with pausable transfers and allowances.
*
* Useful if you want to stop trades until the end of a crowdsale, or have
* an emergency switch for freezing all token transfers in the event of a large
* bug.
*/
contract ERC20Pausable is ERC20, Pausable {
function transfer(address to, uint256 value) public whenNotPaused returns (bool) {
return super.transfer(to, value);
}
function transferFrom(address from, address to, uint256 value) public whenNotPaused returns (bool) {
return super.transferFrom(from, to, value);
}
function approve(address spender, uint256 value) public whenNotPaused returns (bool) {
return super.approve(spender, value);
}
function increaseAllowance(address spender, uint256 addedValue) public whenNotPaused returns (bool) {
return super.increaseAllowance(spender, addedValue);
}
function decreaseAllowance(address spender, uint256 subtractedValue) public whenNotPaused returns (bool) {
return super.decreaseAllowance(spender, subtractedValue);
}
}
// File: @openzeppelin\contracts\access\roles\WhitelistAdminRole.sol
pragma solidity ^0.5.0;
/**
* @title WhitelistAdminRole
* @dev WhitelistAdmins are responsible for assigning and removing Whitelisted accounts.
*/
contract WhitelistAdminRole is Context {
using Roles for Roles.Role;
event WhitelistAdminAdded(address indexed account);
event WhitelistAdminRemoved(address indexed account);
Roles.Role private _whitelistAdmins;
constructor () internal {
_addWhitelistAdmin(_msgSender());
}
modifier onlyWhitelistAdmin() {
require(isWhitelistAdmin(_msgSender()), "WhitelistAdminRole: caller does not have the WhitelistAdmin role");
_;
}
function isWhitelistAdmin(address account) public view returns (bool) {
return _whitelistAdmins.has(account);
}
function addWhitelistAdmin(address account) public onlyWhitelistAdmin {
_addWhitelistAdmin(account);
}
function renounceWhitelistAdmin() public {
_removeWhitelistAdmin(_msgSender());
}
function _addWhitelistAdmin(address account) internal {
_whitelistAdmins.add(account);
emit WhitelistAdminAdded(account);
}
function _removeWhitelistAdmin(address account) internal {
_whitelistAdmins.remove(account);
emit WhitelistAdminRemoved(account);
}
}
// File: contracts\IndividualLockableToken.sol
pragma solidity ^0.5.0;
contract IndividualLockableToken is ERC20Pausable, WhitelistAdminRole{
using SafeMath for uint256;
event LockTimeSetted(address indexed holder, uint256 old_release_time, uint256 new_release_time);
event Locked(address indexed holder, uint256 locked_balance_change, uint256 total_locked_balance, uint256 release_time);
struct lockState {
uint256 locked_balance;
uint256 release_time;
}
// default lock period
uint256 public lock_period = 4 weeks;
mapping(address => lockState) internal userLock;
// Specify the time that a particular person's lock will be released
function setReleaseTime(address _holder, uint256 _release_time)
public
onlyWhitelistAdmin
returns (bool)
{
require(_holder != address(0));
require(_release_time >= block.timestamp);
uint256 old_release_time = userLock[_holder].release_time;
userLock[_holder].release_time = _release_time;
emit LockTimeSetted(_holder, old_release_time, userLock[_holder].release_time);
return true;
}
// Returns the point at which token holder's lock is released
function getReleaseTime(address _holder)
public
view
returns (uint256)
{
require(_holder != address(0));
return userLock[_holder].release_time;
}
// Unlock a specific person. Free trading even with a lock balance
function clearReleaseTime(address _holder)
public
onlyWhitelistAdmin
returns (bool)
{
require(_holder != address(0));
require(userLock[_holder].release_time > 0);
uint256 old_release_time = userLock[_holder].release_time;
userLock[_holder].release_time = 0;
emit LockTimeSetted(_holder, old_release_time, userLock[_holder].release_time);
return true;
}
// Increase the lock balance of a specific person.
// If you only want to increase the balance, the release_time must be specified in advance.
function increaseLockBalance(address _holder, uint256 _value)
public
onlyWhitelistAdmin
returns (bool)
{
require(_holder != address(0));
require(_value > 0);
require(getFreeBalance(_holder) >= _value);
if (userLock[_holder].release_time <= block.timestamp) {
userLock[_holder].release_time = block.timestamp + lock_period;
}
userLock[_holder].locked_balance = (userLock[_holder].locked_balance).add(_value);
emit Locked(_holder, _value, userLock[_holder].locked_balance, userLock[_holder].release_time);
return true;
}
// Increase the lock balance and release time of a specific person.
// If you only want to increase the balance, See increaseLockBalance function.
function increaseLockBalanceWithReleaseTime(address _holder, uint256 _value, uint256 _release_time)
public
onlyWhitelistAdmin
returns (bool)
{
require(_holder != address(0));
require(_value > 0);
require(getFreeBalance(_holder) >= _value);
require(_release_time >= block.timestamp);
uint256 old_release_time = userLock[_holder].release_time;
userLock[_holder].release_time = _release_time;
emit LockTimeSetted(_holder, old_release_time, userLock[_holder].release_time);
userLock[_holder].locked_balance = (userLock[_holder].locked_balance).add(_value);
emit Locked(_holder, _value, userLock[_holder].locked_balance, userLock[_holder].release_time);
return true;
}
// Decrease the lock balance of a specific person.
function decreaseLockBalance(address _holder, uint256 _value)
public
onlyWhitelistAdmin
returns (bool)
{
require(_holder != address(0));
require(_value > 0);
require(userLock[_holder].locked_balance >= _value);
userLock[_holder].locked_balance = (userLock[_holder].locked_balance).sub(_value);
emit Locked(_holder, _value, userLock[_holder].locked_balance, userLock[_holder].release_time);
return true;
}
// Clear the lock.
function clearLock(address _holder)
public
onlyWhitelistAdmin
returns (bool)
{
require(_holder != address(0));
userLock[_holder].locked_balance = 0;
userLock[_holder].release_time = 0;
emit Locked(_holder, 0, userLock[_holder].locked_balance, userLock[_holder].release_time);
return true;
}
// Check the amount of the lock
function getLockedBalance(address _holder)
public
view
returns (uint256)
{
if(block.timestamp >= userLock[_holder].release_time) return uint256(0);
return userLock[_holder].locked_balance;
}
// Check your remaining balance
function getFreeBalance(address _holder)
public
view
returns (uint256)
{
if(block.timestamp >= userLock[_holder].release_time ) return balanceOf(_holder);
if(balanceOf(_holder) <= userLock[_holder].locked_balance) return uint256(0);
return balanceOf(_holder).sub(userLock[_holder].locked_balance);
}
// transfer overrride
function transfer(
address _to,
uint256 _value
)
public
returns (bool)
{
require(getFreeBalance(_msgSender()) >= _value);
return super.transfer(_to, _value);
}
// transferFrom overrride
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(getFreeBalance(_from) >= _value);
return super.transferFrom(_from, _to, _value);
}
// approve overrride
function approve(
address _spender,
uint256 _value
)
public
returns (bool)
{
require(getFreeBalance(_msgSender()) >= _value);
return super.approve(_spender, _value);
}
// increaseAllowance overrride
function increaseAllowance(
address _spender,
uint _addedValue
)
public
returns (bool success)
{
require(getFreeBalance(_msgSender()) >= allowance(_msgSender(), _spender).add(_addedValue));
return super.increaseAllowance(_spender, _addedValue);
}
// decreaseAllowance overrride
function decreaseAllowance(
address _spender,
uint _subtractedValue
)
public
returns (bool success)
{
uint256 oldValue = allowance(_msgSender(), _spender);
if (_subtractedValue < oldValue) {
require(getFreeBalance(_msgSender()) >= oldValue.sub(_subtractedValue));
}
return super.decreaseAllowance(_spender, _subtractedValue);
}
function renounceWhitelistAdmin()
public
{
_removeWhitelistAdmin(_msgSender());
}
}
// File: contracts\MocaCoin.sol
pragma solidity ^0.5.0;
contract MocaCoin is IndividualLockableToken {
using SafeMath for uint256;
string public constant name = "MocaCoin";
string public constant symbol = "MCC";
uint8 public constant decimals = 18;
uint256 public constant INITIAL_SUPPLY = 11900000000 * (10 ** uint256(decimals));
constructor()
public
{
_mint(_msgSender(), INITIAL_SUPPLY);
}
}
Read Contract
INITIAL_SUPPLY 0x2ff2e9dc → uint256
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
decimals 0x313ce567 → uint8
getFreeBalance 0x8870985b → uint256
getLockedBalance 0xc4086893 → uint256
getReleaseTime 0x0cb7eb4c → uint256
isPauser 0x46fbf68e → bool
isWhitelistAdmin 0xbb5f747b → bool
lock_period 0xf83e9a20 → uint256
name 0x06fdde03 → string
paused 0x5c975abb → bool
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
Write Contract 17 functions
These functions modify contract state and require a wallet transaction to execute.
addPauser 0x82dc1ec4
address account
addWhitelistAdmin 0x7362d9c8
address account
approve 0x095ea7b3
address _spender
uint256 _value
returns: bool
clearLock 0x8dc73521
address _holder
returns: bool
clearReleaseTime 0xa31052e8
address _holder
returns: bool
decreaseAllowance 0xa457c2d7
address _spender
uint256 _subtractedValue
returns: bool
decreaseLockBalance 0x6c4e5c86
address _holder
uint256 _value
returns: bool
increaseAllowance 0x39509351
address _spender
uint256 _addedValue
returns: bool
increaseLockBalance 0xe6108fc9
address _holder
uint256 _value
returns: bool
increaseLockBalanceWithReleaseTime 0x9e20749a
address _holder
uint256 _value
uint256 _release_time
returns: bool
pause 0x8456cb59
No parameters
renouncePauser 0x6ef8d66d
No parameters
renounceWhitelistAdmin 0x4c5a628c
No parameters
setReleaseTime 0x476fe919
address _holder
uint256 _release_time
returns: bool
transfer 0xa9059cbb
address _to
uint256 _value
returns: bool
transferFrom 0x23b872dd
address _from
address _to
uint256 _value
returns: bool
unpause 0x3f4ba83a
No parameters
Recent Transactions
This address has 1 on-chain transactions, but only 1.3% of the chain is indexed. Transactions will appear as indexing progresses. View on Etherscan →