1

I'm planning to create my own token (Binance Smart Chaine C.) my first attempt was succesfull. But I'm trying to figure out how to avoid price dumping by whales. A Solution would be if i could adjust the selling fee like safemoon does (10%) but i haven't found the line in the code to set the fee.

I know that this question is very general, but maybe someone could help me a bit fourther.

Thanks

1

from the pancake Cake token smart contract:

/**
     * @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), 'BEP20: transfer from the zero address');
        require(recipient != address(0), 'BEP20: transfer to the zero address');

        _balances[sender] = _balances[sender].sub(amount, 'BEP20: transfer amount exceeds balance');
        _balances[recipient] = _balances[recipient].add(amount);
        emit Transfer(sender, recipient, amount);
    }

in that function, you can add a second amount that is calculated based on the amount being transferred (e.g 10%) and add that to the subbed amount when testing if the balance is sufficient. Then you can finish the transfer with the original amount and create another transfer with the fee amount to your personal address or the contract address or any owner address you want.

1
  • 1
    Thank you very much!
    – DeDev
    May 14 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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