Giter Club home page Giter Club logo

pinkmoonfinance_pink-antibot-guide's Introduction

PinkAntiBot Contract Address:

  1. MAINNET: 0xf4f071EB637b64fC78C9eA87DaCE4445D119CA35
  2. BSC: 0x8EFDb3b642eb2a20607ffe0A56CFefF6a95Df002
  3. BSC_TESTNET: 0xbb06F5C7689eA93d9DeACCf4aF8546C4Fe0Bf1E5
  4. MATIC: 0x56a79881b65B03F27b088B753B6c128485642FC3
  5. KCC_MAINNET: 0x2A7F08C820f3382D38B855ba59ad26444938a2b5
  6. AVAX: 0x18F349aD12d7d7f029B3b22e0B01c6D88a0D2066
  7. FTM: 0xcA461AcF6A9E68FA6D53410eba43cefde7dF5466
  8. CRONOS: 0x785A195F7b6a0dDaf7E41EBcBddE7a98F4Cb24A9

PinkAntiBot integration guide

  1. Add this interface to your codebase:

IPinkAntiBot.sol

// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0;

interface IPinkAntiBot {
  function setTokenOwner(address owner) external;

  function onPreTransferCheck(
    address from,
    address to,
    uint256 amount
  ) external;
}
  1. Update your token contract:
+import "path/to/IPinkAntiBot.sol";

contract MyToken {
+ IPinkAntiBot public pinkAntiBot;

  constructor(
    string memory name_,
    string memory symbol_,
    uint8 decimals_,
    uint256 totalSupply_,
+   address pinkAntiBot_ 
  ) {
    ... omitted for clarity

    // Create an instance of the PinkAntiBot variable from the provided address
+   pinkAntiBot = IPinkAntiBot(pinkAntiBot_);
    // Register the deployer to be the token owner with PinkAntiBot. You can
    // later change the token owner in the PinkAntiBot contract
+   pinkAntiBot.setTokenOwner(msg.sender);
  }

  // Inside ERC20's _transfer function:
  function _transfer(
    address sender,
    address recipient,
    uint256 amount
  ) internal virtual {
    require(sender != address(0), "ERC20: transfer from the zero address");
    require(recipient != address(0), "ERC20: transfer to the zero address");
+   pinkAntiBot.onPreTransferCheck(sender, recipient, amount);
  }
}
  1. Visit https://www.pinksale.finance/#/antibot, update your settings. After that please enable Pink Anti-Bot (Pay 1 BNB fee at first time)

alt text

  1. (Optional): If you want more control over how PinkAntiBot is enabled or disabled, you can do it inside your contract instead of relying on PinkAntiBot contract's configuration:
import "path/to/IPinkAntiBot.sol";

contract MyToken {
  IPinkAntiBot public pinkAntiBot;
+ bool public antiBotEnabled;

  constructor(
    string memory name_,
    string memory symbol_,
    uint8 decimals_,
    uint256 totalSupply_,
    address pinkAntiBot_ 
  ) {
    ... omitted for clarity

    // Create an instance of the PinkAntiBot variable from the provided address
    pinkAntiBot = IPinkAntiBot(pinkAntiBot_);
    // Register the deployer to be the token owner with PinkAntiBot. You can
    // later change the token owner in the PinkAntiBot contract
    pinkAntiBot.setTokenOwner(msg.sender);
+   antiBotEnabled = true;
  }

  // Use this function to control whether to use PinkAntiBot or not instead
  // of managing this in the PinkAntiBot contract
+ function setEnableAntiBot(bool _enable) external onlyOwner {
+   antiBotEnabled = _enable;
+ }

  // Inside ERC20's _transfer function:
  function _transfer(
    address sender,
    address recipient,
    uint256 amount
  ) internal virtual {
    require(sender != address(0), "ERC20: transfer from the zero address");
    require(recipient != address(0), "ERC20: transfer to the zero address");
    // Only use PinkAntiBot if this state is true
+   if (antiBotEnabled) {
      pinkAntiBot.onPreTransferCheck(sender, recipient, amount);
+   }
  }
}

pinkmoonfinance_pink-antibot-guide's People

Contributors

pinkmoonfinance avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.