0

I've added tokens to pancakeswap before, and it was easy, but now it doesnt work anymore... perhaps I am doing something really dumb, but I can't seem to figure it out and could use a little help.

I have a smart contract token on the BSC mainnet with the address: 0x01a5bf8decb165db30451225dd2d74f034ffe678

But I just can't figure out how to add it, I've tried going to pancakswap > liquidity > add liquidity > clicking the token > pasting my smart contract address

Heres a screen shot of it doing nothing. I've tried manage tokens also.

mainnet

I've also tried going to pancakswap testnet > liquidity > add liquidity > clicking the token > manage tokens > tokens > pasting the smart contract address

(screenshot of this testnet below)

Has pancakeswap changed to only allow coingeko approved coins or something? I've tried the testnet too and nothing works.

Here is a screen shot of it not doing anything on the testnet: testnet

And here is my tokens smart contract... it takes BNB coin as payment and returns tokens in a fundraiser. I could use some help figuring this out... am I missing something really obvious?

// SPDX-License-Identifier: MIT

pragma solidity ^0.8;

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.
     */
    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.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        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.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}


interface IBEP20 {
  /**
   * @dev Returns the amount of tokens in existence.
   */
  function totalSupply() external view returns (uint256);

  /**
   * @dev Returns the token decimals.
   */
  function decimals() external view returns (uint8);

  /**
   * @dev Returns the token symbol.
   */
  function symbol() external view returns (string memory);

  /**
  * @dev Returns the token name.
  */
  function name() external view returns (string memory);

  /**
   * @dev Returns the bep token owner.
   */
  function getOwner() external view returns (address);

  /**
   * @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);
}

contract TokenName is IBEP20 {
    using SafeMath for uint256;

    string public name_ = "Token Name";
    string public symbol_ = "TOKENNAME";
    uint8 public decimals = 18;
    address public creator;
    uint256 public ethRaised = 0;
    bool public endFundraise = false;
    bool private _locked; // Flag to prevent re-entrancy

    mapping(address => uint256) public storeCoins;
    mapping(address => uint256) public balanceOf_;
    mapping(address => bool) public claimed;

    uint256 totalSupply_ = 2400000000000000 * 10**18;

    event FundingEnded();

    modifier onlyCreator() {
        require(msg.sender == creator, "Only creator can call this function");
        _;
    }

    constructor() {
        creator = msg.sender;
        balanceOf_[msg.sender] += 600000000000000 * 10**18;//assign quater the tokens to the team (600 trillion) 
        balanceOf_[msg.sender] += 1200000000000000 * 10**18;//assign half the tokens for liquidity (1200 trillion) 
        
        emit Transfer(address(0), msg.sender,  600000000000000 * 10**18);//600 trillion
        emit Transfer(address(0), msg.sender,  1200000000000000 * 10**18);//1200 trillion
    }

    function getOwner() external view override returns (address) {
        return creator;
    }

    function name() external view override returns (string memory) {
        return name_;
    }

    function symbol() external view override returns (string memory) {
        return symbol_;
    }


    function totalSupply() external view override returns (uint256) {
        return totalSupply_;
    }

    function balanceOf(address account) external view override returns (uint256) {
        return balanceOf_[account];
    }

    function transfer(address recipient, uint256 amount) external override returns (bool) {
        _transfer(msg.sender, recipient, amount);
        return true;
    }

    function allowance(address, address) external pure returns (uint256) {
        revert("No allowances in this contract");
    }

    function approve(address, uint256) external pure returns (bool) {
        revert("No approvals in this contract");
    }

    function transferFrom(address, address, uint256) external pure returns (bool) {
        revert("No transfers from this contract");
    }

    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");
        require(balanceOf_[sender] >= amount, "ERC20: transfer amount exceeds balance");
        
        balanceOf_[sender] -= amount;
        balanceOf_[recipient] += amount;
        emit Transfer(sender, recipient, amount);
    }

    function withdraw() public onlyCreator {
        require(!_locked, "Reentrant call detected");
        _locked = true; // Lock before external call
        payable(creator).transfer(address(this).balance);
        _locked = false; // Unlock after external call
    }

    function endFunding() public onlyCreator {
        require(!_locked, "Reentrant call detected");
        _locked = true; // Lock before external call
        endFundraise = true;
        emit FundingEnded();
        _locked = false; // Unlock after external call
    }

    function getCoins() public {
        require(!_locked, "Reentrant call detected");
        _locked = true; // Lock before external call
        require(endFundraise == true, "Fundraising is not yet ended");
        require(storeCoins[msg.sender] > 0, "You need to deposit Ether first");
        require(!claimed[msg.sender], "Tokens already claimed");

        claimed[msg.sender] = true;
        balanceOf_[msg.sender] += storeCoins[msg.sender];
        storeCoins[msg.sender] = 0;
        emit Transfer(address(0), msg.sender, balanceOf_[msg.sender]);
        _locked = false; // Unlock after external call
    }

    function deposit(uint256 amount) payable public {
        require(!_locked, "Reentrant call detected");
        _locked = true; // Lock before external call
        require(msg.value == amount);
        require(ethRaised < 15000 * 10**18);
        require(!claimed[msg.sender], "Tokens already claimed");
        require(ethRaised < 15000 * 10**18, "Fundraising goal reached");
        require(!endFundraise, "Fundraising ended");
    
        if (ethRaised < 3000 * 10**18) {//3000 * 10**18
            storeCoins[msg.sender] += msg.value * 50000000000;
        } else if (ethRaised >= 3000 * 10**18 && ethRaised < 6000 * 10**18) {//
            storeCoins[msg.sender] += msg.value * 45000000000;
        } else if (ethRaised >= 6000 * 10**18 && ethRaised < 9000 * 10**18) {
            storeCoins[msg.sender] += msg.value * 40000000000;
        } else if (ethRaised >= 9000 * 10**18 && ethRaised < 12000 * 10**18) {
            storeCoins[msg.sender] += msg.value * 35000000000;
        } else if (ethRaised >= 12000 * 10**18 ) {//&& ethRaised < 15000 * 10**18 ... the fundraiser goal
            storeCoins[msg.sender] += msg.value * 30000000000;
        }
        
        ethRaised += msg.value;
        _locked = false; // Unlock after external call
    }

    function getBalance() public view returns (uint256) {
        return storeCoins[msg.sender];
    }

    function getEthRaised() public view returns (uint256) {
        return ethRaised;
    }

}

1 Answer 1

0

After investigation I found that there are errors in the Smart Contract I was using, and using another Smart Contract resolved the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.