Advertisement
X-Grats

PEPE

Oct 14th, 2023
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.32 KB | Cryptocurrency | 0 0
  1. // Sources flattened with hardhat v2.7.0 https://hardhat.org
  2.  
  3. // File @openzeppelin/contracts/utils/Context.sol@v4.4.0
  4.  
  5. // SPDX-License-Identifier: MIT
  6. // OpenZeppelin Contracts v4.4.0 (utils/Context.sol)
  7.  
  8. pragma solidity ^0.8.0;
  9.  
  10. /**
  11. * @dev Provides information about the current execution context, including the
  12. * sender of the transaction and its data. While these are generally available
  13. * via msg.sender and msg.data, they should not be accessed in such a direct
  14. * manner, since when dealing with meta-transactions the account sending and
  15. * paying for execution may not be the actual sender (as far as an application
  16. * is concerned).
  17. *
  18. * This contract is only required for intermediate, library-like contracts.
  19. */
  20. abstract contract Context {
  21. function _msgSender() internal view virtual returns (address) {
  22. return msg.sender;
  23. }
  24.  
  25. function _msgData() internal view virtual returns (bytes calldata) {
  26. return msg.data;
  27. }
  28. }
  29.  
  30.  
  31. // File @openzeppelin/contracts/access/Ownable.sol@v4.4.0
  32.  
  33.  
  34. // OpenZeppelin Contracts v4.4.0 (access/Ownable.sol)
  35.  
  36. pragma solidity ^0.8.0;
  37.  
  38. /**
  39. * @dev Contract module which provides a basic access control mechanism, where
  40. * there is an account (an owner) that can be granted exclusive access to
  41. * specific functions.
  42. *
  43. * By default, the owner account will be the one that deploys the contract. This
  44. * can later be changed with {transferOwnership}.
  45. *
  46. * This module is used through inheritance. It will make available the modifier
  47. * `onlyOwner`, which can be applied to your functions to restrict their use to
  48. * the owner.
  49. */
  50. abstract contract Ownable is Context {
  51. address private _owner;
  52.  
  53. event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
  54.  
  55. /**
  56. * @dev Initializes the contract setting the deployer as the initial owner.
  57. */
  58. constructor() {
  59. _transferOwnership(_msgSender());
  60. }
  61.  
  62. /**
  63. * @dev Returns the address of the current owner.
  64. */
  65. function owner() public view virtual returns (address) {
  66. return _owner;
  67. }
  68.  
  69. /**
  70. * @dev Throws if called by any account other than the owner.
  71. */
  72. modifier onlyOwner() {
  73. require(owner() == _msgSender(), "Ownable: caller is not the owner");
  74. _;
  75. }
  76.  
  77. /**
  78. * @dev Leaves the contract without owner. It will not be possible to call
  79. * `onlyOwner` functions anymore. Can only be called by the current owner.
  80. *
  81. * NOTE: Renouncing ownership will leave the contract without an owner,
  82. * thereby removing any functionality that is only available to the owner.
  83. */
  84. function renounceOwnership() public virtual onlyOwner {
  85. _transferOwnership(address(0));
  86. }
  87.  
  88. /**
  89. * @dev Transfers ownership of the contract to a new account (`newOwner`).
  90. * Can only be called by the current owner.
  91. */
  92. function transferOwnership(address newOwner) public virtual onlyOwner {
  93. require(newOwner != address(0), "Ownable: new owner is the zero address");
  94. _transferOwnership(newOwner);
  95. }
  96.  
  97. /**
  98. * @dev Transfers ownership of the contract to a new account (`newOwner`).
  99. * Internal function without access restriction.
  100. */
  101. function _transferOwnership(address newOwner) internal virtual {
  102. address oldOwner = _owner;
  103. _owner = newOwner;
  104. emit OwnershipTransferred(oldOwner, newOwner);
  105. }
  106. }
  107.  
  108.  
  109. // File @openzeppelin/contracts/token/ERC20/IERC20.sol@v4.4.0
  110.  
  111.  
  112. // OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol)
  113.  
  114. pragma solidity ^0.8.0;
  115.  
  116. /**
  117. * @dev Interface of the ERC20 standard as defined in the EIP.
  118. */
  119. interface IERC20 {
  120. /**
  121. * @dev Returns the amount of tokens in existence.
  122. */
  123. function totalSupply() external view returns (uint256);
  124.  
  125. /**
  126. * @dev Returns the amount of tokens owned by `account`.
  127. */
  128. function balanceOf(address account) external view returns (uint256);
  129.  
  130. /**
  131. * @dev Moves `amount` tokens from the caller's account to `recipient`.
  132. *
  133. * Returns a boolean value indicating whether the operation succeeded.
  134. *
  135. * Emits a {Transfer} event.
  136. */
  137. function transfer(address recipient, uint256 amount) external returns (bool);
  138.  
  139. /**
  140. * @dev Returns the remaining number of tokens that `spender` will be
  141. * allowed to spend on behalf of `owner` through {transferFrom}. This is
  142. * zero by default.
  143. *
  144. * This value changes when {approve} or {transferFrom} are called.
  145. */
  146. function allowance(address owner, address spender) external view returns (uint256);
  147.  
  148. /**
  149. * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
  150. *
  151. * Returns a boolean value indicating whether the operation succeeded.
  152. *
  153. * IMPORTANT: Beware that changing an allowance with this method brings the risk
  154. * that someone may use both the old and the new allowance by unfortunate
  155. * transaction ordering. One possible solution to mitigate this race
  156. * condition is to first reduce the spender's allowance to 0 and set the
  157. * desired value afterwards:
  158. * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
  159. *
  160. * Emits an {Approval} event.
  161. */
  162. function approve(address spender, uint256 amount) external returns (bool);
  163.  
  164. /**
  165. * @dev Moves `amount` tokens from `sender` to `recipient` using the
  166. * allowance mechanism. `amount` is then deducted from the caller's
  167. * allowance.
  168. *
  169. * Returns a boolean value indicating whether the operation succeeded.
  170. *
  171. * Emits a {Transfer} event.
  172. */
  173. function transferFrom(
  174. address sender,
  175. address recipient,
  176. uint256 amount
  177. ) external returns (bool);
  178.  
  179. /**
  180. * @dev Emitted when `value` tokens are moved from one account (`from`) to
  181. * another (`to`).
  182. *
  183. * Note that `value` may be zero.
  184. */
  185. event Transfer(address indexed from, address indexed to, uint256 value);
  186.  
  187. /**
  188. * @dev Emitted when the allowance of a `spender` for an `owner` is set by
  189. * a call to {approve}. `value` is the new allowance.
  190. */
  191. event Approval(address indexed owner, address indexed spender, uint256 value);
  192. }
  193.  
  194.  
  195. // File @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol@v4.4.0
  196.  
  197.  
  198. // OpenZeppelin Contracts v4.4.0 (token/ERC20/extensions/IERC20Metadata.sol)
  199.  
  200. pragma solidity ^0.8.0;
  201.  
  202. /**
  203. * @dev Interface for the optional metadata functions from the ERC20 standard.
  204. *
  205. * _Available since v4.1._
  206. */
  207. interface IERC20Metadata is IERC20 {
  208. /**
  209. * @dev Returns the name of the token.
  210. */
  211. function name() external view returns (string memory);
  212.  
  213. /**
  214. * @dev Returns the symbol of the token.
  215. */
  216. function symbol() external view returns (string memory);
  217.  
  218. /**
  219. * @dev Returns the decimals places of the token.
  220. */
  221. function decimals() external view returns (uint8);
  222. }
  223.  
  224.  
  225. // File @openzeppelin/contracts/token/ERC20/ERC20.sol@v4.4.0
  226.  
  227.  
  228. // OpenZeppelin Contracts v4.4.0 (token/ERC20/ERC20.sol)
  229.  
  230. pragma solidity ^0.8.0;
  231.  
  232.  
  233.  
  234. /**
  235. * @dev Implementation of the {IERC20} interface.
  236. *
  237. * This implementation is agnostic to the way tokens are created. This means
  238. * that a supply mechanism has to be added in a derived contract using {_mint}.
  239. * For a generic mechanism see {ERC20PresetMinterPauser}.
  240. *
  241. * TIP: For a detailed writeup see our guide
  242. * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
  243. * to implement supply mechanisms].
  244. *
  245. * We have followed general OpenZeppelin Contracts guidelines: functions revert
  246. * instead returning `false` on failure. This behavior is nonetheless
  247. * conventional and does not conflict with the expectations of ERC20
  248. * applications.
  249. *
  250. * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
  251. * This allows applications to reconstruct the allowance for all accounts just
  252. * by listening to said events. Other implementations of the EIP may not emit
  253. * these events, as it isn't required by the specification.
  254. *
  255. * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
  256. * functions have been added to mitigate the well-known issues around setting
  257. * allowances. See {IERC20-approve}.
  258. */
  259. contract ERC20 is Context, IERC20, IERC20Metadata {
  260. mapping(address => uint256) private _balances;
  261.  
  262. mapping(address => mapping(address => uint256)) private _allowances;
  263.  
  264. uint256 private _totalSupply;
  265.  
  266. string private _name;
  267. string private _symbol;
  268.  
  269. /**
  270. * @dev Sets the values for {name} and {symbol}.
  271. *
  272. * The default value of {decimals} is 18. To select a different value for
  273. * {decimals} you should overload it.
  274. *
  275. * All two of these values are immutable: they can only be set once during
  276. * construction.
  277. */
  278. constructor(string memory name_, string memory symbol_) {
  279. _name = name_;
  280. _symbol = symbol_;
  281. }
  282.  
  283. /**
  284. * @dev Returns the name of the token.
  285. */
  286. function name() public view virtual override returns (string memory) {
  287. return _name;
  288. }
  289.  
  290. /**
  291. * @dev Returns the symbol of the token, usually a shorter version of the
  292. * name.
  293. */
  294. function symbol() public view virtual override returns (string memory) {
  295. return _symbol;
  296. }
  297.  
  298. /**
  299. * @dev Returns the number of decimals used to get its user representation.
  300. * For example, if `decimals` equals `2`, a balance of `505` tokens should
  301. * be displayed to a user as `5.05` (`505 / 10 ** 2`).
  302. *
  303. * Tokens usually opt for a value of 18, imitating the relationship between
  304. * Ether and Wei. This is the value {ERC20} uses, unless this function is
  305. * overridden;
  306. *
  307. * NOTE: This information is only used for _display_ purposes: it in
  308. * no way affects any of the arithmetic of the contract, including
  309. * {IERC20-balanceOf} and {IERC20-transfer}.
  310. */
  311. function decimals() public view virtual override returns (uint8) {
  312. return 18;
  313. }
  314.  
  315. /**
  316. * @dev See {IERC20-totalSupply}.
  317. */
  318. function totalSupply() public view virtual override returns (uint256) {
  319. return _totalSupply;
  320. }
  321.  
  322. /**
  323. * @dev See {IERC20-balanceOf}.
  324. */
  325. function balanceOf(address account) public view virtual override returns (uint256) {
  326. return _balances[account];
  327. }
  328.  
  329. /**
  330. * @dev See {IERC20-transfer}.
  331. *
  332. * Requirements:
  333. *
  334. * - `recipient` cannot be the zero address.
  335. * - the caller must have a balance of at least `amount`.
  336. */
  337. function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
  338. _transfer(_msgSender(), recipient, amount);
  339. return true;
  340. }
  341.  
  342. /**
  343. * @dev See {IERC20-allowance}.
  344. */
  345. function allowance(address owner, address spender) public view virtual override returns (uint256) {
  346. return _allowances[owner][spender];
  347. }
  348.  
  349. /**
  350. * @dev See {IERC20-approve}.
  351. *
  352. * Requirements:
  353. *
  354. * - `spender` cannot be the zero address.
  355. */
  356. function approve(address spender, uint256 amount) public virtual override returns (bool) {
  357. _approve(_msgSender(), spender, amount);
  358. return true;
  359. }
  360.  
  361. /**
  362. * @dev See {IERC20-transferFrom}.
  363. *
  364. * Emits an {Approval} event indicating the updated allowance. This is not
  365. * required by the EIP. See the note at the beginning of {ERC20}.
  366. *
  367. * Requirements:
  368. *
  369. * - `sender` and `recipient` cannot be the zero address.
  370. * - `sender` must have a balance of at least `amount`.
  371. * - the caller must have allowance for ``sender``'s tokens of at least
  372. * `amount`.
  373. */
  374. function transferFrom(
  375. address sender,
  376. address recipient,
  377. uint256 amount
  378. ) public virtual override returns (bool) {
  379. _transfer(sender, recipient, amount);
  380.  
  381. uint256 currentAllowance = _allowances[sender][_msgSender()];
  382. require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
  383. unchecked {
  384. _approve(sender, _msgSender(), currentAllowance - amount);
  385. }
  386.  
  387. return true;
  388. }
  389.  
  390. /**
  391. * @dev Atomically increases the allowance granted to `spender` by the caller.
  392. *
  393. * This is an alternative to {approve} that can be used as a mitigation for
  394. * problems described in {IERC20-approve}.
  395. *
  396. * Emits an {Approval} event indicating the updated allowance.
  397. *
  398. * Requirements:
  399. *
  400. * - `spender` cannot be the zero address.
  401. */
  402. function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
  403. _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
  404. return true;
  405. }
  406.  
  407. /**
  408. * @dev Atomically decreases the allowance granted to `spender` by the caller.
  409. *
  410. * This is an alternative to {approve} that can be used as a mitigation for
  411. * problems described in {IERC20-approve}.
  412. *
  413. * Emits an {Approval} event indicating the updated allowance.
  414. *
  415. * Requirements:
  416. *
  417. * - `spender` cannot be the zero address.
  418. * - `spender` must have allowance for the caller of at least
  419. * `subtractedValue`.
  420. */
  421. function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
  422. uint256 currentAllowance = _allowances[_msgSender()][spender];
  423. require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
  424. unchecked {
  425. _approve(_msgSender(), spender, currentAllowance - subtractedValue);
  426. }
  427.  
  428. return true;
  429. }
  430.  
  431. /**
  432. * @dev Moves `amount` of tokens from `sender` to `recipient`.
  433. *
  434. * This internal function is equivalent to {transfer}, and can be used to
  435. * e.g. implement automatic token fees, slashing mechanisms, etc.
  436. *
  437. * Emits a {Transfer} event.
  438. *
  439. * Requirements:
  440. *
  441. * - `sender` cannot be the zero address.
  442. * - `recipient` cannot be the zero address.
  443. * - `sender` must have a balance of at least `amount`.
  444. */
  445. function _transfer(
  446. address sender,
  447. address recipient,
  448. uint256 amount
  449. ) internal virtual {
  450. require(sender != address(0), "ERC20: transfer from the zero address");
  451. require(recipient != address(0), "ERC20: transfer to the zero address");
  452.  
  453. _beforeTokenTransfer(sender, recipient, amount);
  454.  
  455. uint256 senderBalance = _balances[sender];
  456. require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
  457. unchecked {
  458. _balances[sender] = senderBalance - amount;
  459. }
  460. _balances[recipient] += amount;
  461.  
  462. emit Transfer(sender, recipient, amount);
  463.  
  464. _afterTokenTransfer(sender, recipient, amount);
  465. }
  466.  
  467. /** @dev Creates `amount` tokens and assigns them to `account`, increasing
  468. * the total supply.
  469. *
  470. * Emits a {Transfer} event with `from` set to the zero address.
  471. *
  472. * Requirements:
  473. *
  474. * - `account` cannot be the zero address.
  475. */
  476. function _mint(address account, uint256 amount) internal virtual {
  477. require(account != address(0), "ERC20: mint to the zero address");
  478.  
  479. _beforeTokenTransfer(address(0), account, amount);
  480.  
  481. _totalSupply += amount;
  482. _balances[account] += amount;
  483. emit Transfer(address(0), account, amount);
  484.  
  485. _afterTokenTransfer(address(0), account, amount);
  486. }
  487.  
  488. /**
  489. * @dev Destroys `amount` tokens from `account`, reducing the
  490. * total supply.
  491. *
  492. * Emits a {Transfer} event with `to` set to the zero address.
  493. *
  494. * Requirements:
  495. *
  496. * - `account` cannot be the zero address.
  497. * - `account` must have at least `amount` tokens.
  498. */
  499. function _burn(address account, uint256 amount) internal virtual {
  500. require(account != address(0), "ERC20: burn from the zero address");
  501.  
  502. _beforeTokenTransfer(account, address(0), amount);
  503.  
  504. uint256 accountBalance = _balances[account];
  505. require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
  506. unchecked {
  507. _balances[account] = accountBalance - amount;
  508. }
  509. _totalSupply -= amount;
  510.  
  511. emit Transfer(account, address(0), amount);
  512.  
  513. _afterTokenTransfer(account, address(0), amount);
  514. }
  515.  
  516. /**
  517. * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
  518. *
  519. * This internal function is equivalent to `approve`, and can be used to
  520. * e.g. set automatic allowances for certain subsystems, etc.
  521. *
  522. * Emits an {Approval} event.
  523. *
  524. * Requirements:
  525. *
  526. * - `owner` cannot be the zero address.
  527. * - `spender` cannot be the zero address.
  528. */
  529. function _approve(
  530. address owner,
  531. address spender,
  532. uint256 amount
  533. ) internal virtual {
  534. require(owner != address(0), "ERC20: approve from the zero address");
  535. require(spender != address(0), "ERC20: approve to the zero address");
  536.  
  537. _allowances[owner][spender] = amount;
  538. emit Approval(owner, spender, amount);
  539. }
  540.  
  541. /**
  542. * @dev Hook that is called before any transfer of tokens. This includes
  543. * minting and burning.
  544. *
  545. * Calling conditions:
  546. *
  547. * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
  548. * will be transferred to `to`.
  549. * - when `from` is zero, `amount` tokens will be minted for `to`.
  550. * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
  551. * - `from` and `to` are never both zero.
  552. *
  553. * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
  554. */
  555. function _beforeTokenTransfer(
  556. address from,
  557. address to,
  558. uint256 amount
  559. ) internal virtual {}
  560.  
  561. /**
  562. * @dev Hook that is called after any transfer of tokens. This includes
  563. * minting and burning.
  564. *
  565. * Calling conditions:
  566. *
  567. * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
  568. * has been transferred to `to`.
  569. * - when `from` is zero, `amount` tokens have been minted for `to`.
  570. * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
  571. * - `from` and `to` are never both zero.
  572. *
  573. * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
  574. */
  575. function _afterTokenTransfer(
  576. address from,
  577. address to,
  578. uint256 amount
  579. ) internal virtual {}
  580. }
  581.  
  582.  
  583. // File contracts/PepeToken.sol
  584.  
  585.  
  586.  
  587. pragma solidity ^0.8.0;
  588.  
  589.  
  590. contract PepeJunior is Ownable, ERC20 {
  591. bool public limited;
  592. uint256 public maxHoldingAmount;
  593. uint256 public minHoldingAmount;
  594. address public uniswapV2Pair;
  595. mapping(address => bool) public blacklists;
  596.  
  597. constructor(uint256 _totalSupply) ERC20("Pepe Junior", "PEPE") {
  598. _mint(msg.sender, _totalSupply);
  599. }
  600.  
  601. function blacklist(address _address, bool _isBlacklisting) external onlyOwner {
  602. blacklists[_address] = _isBlacklisting;
  603. }
  604.  
  605. function setRule(bool _limited, address _uniswapV2Pair, uint256 _maxHoldingAmount, uint256 _minHoldingAmount) external onlyOwner {
  606. limited = _limited;
  607. uniswapV2Pair = _uniswapV2Pair;
  608. maxHoldingAmount = _maxHoldingAmount;
  609. minHoldingAmount = _minHoldingAmount;
  610. }
  611.  
  612. function _beforeTokenTransfer(
  613. address from,
  614. address to,
  615. uint256 amount
  616. ) override internal virtual {
  617. require(!blacklists[to] && !blacklists[from], "Blacklisted");
  618.  
  619. if (uniswapV2Pair == address(0)) {
  620. require(from == owner() || to == owner(), "trading is not started");
  621. return;
  622. }
  623.  
  624. if (limited && from == uniswapV2Pair) {
  625. require(super.balanceOf(to) + amount <= maxHoldingAmount && super.balanceOf(to) + amount >= minHoldingAmount, "Forbid");
  626. }
  627. }
  628.  
  629. function burn(uint256 value) external {
  630. _burn(msg.sender, value);
  631. }
  632. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement