I want 2% of transactions to go to the charity wallet

Hi I am new to all of this. I have started a new coin on BSC chain and I want 2% of transactions to go to the charity wallet. Is there any way I could do that simply? Thanks in advance for any help

Check YUMMY token on BSCscan or MUNCH on etherescan

1 Like

I am looking at the YUMMY contract. It seems what they are doing is swap and liquify. Does that mean half of the liquidity pool tax goes to the charity wallet as BNB? And if I just paste the following lines of code, do you think it would work for my coin?

function swapAndLiquify(uint256 contractTokenBalance) private lockTheSwap {
// split the contract balance into thirds
uint256 halfOfLiquify = contractTokenBalance.div(4);
uint256 otherHalfOfLiquify = contractTokenBalance.div(4);
uint256 portionForFees = contractTokenBalance.sub(halfOfLiquify).sub(otherHalfOfLiquify);

    // capture the contract's current ETH balance.
    // this is so that we can capture exactly the amount of ETH that the
    // swap creates, and not make the liquidity event include any ETH that
    // has been manually sent to the contract
    uint256 initialBalance = address(this).balance;

    // swap tokens for ETH
    swapTokensForEth(halfOfLiquify); // <- this breaks the ETH -> HATE swap when swap+liquify is triggered

    // how much ETH did we just swap into?
    uint256 newBalance = address(this).balance.sub(initialBalance);

    // add liquidity to uniswap
    addLiquidity(otherHalfOfLiquify, newBalance);
    emit SwapAndLiquify(halfOfLiquify, newBalance, otherHalfOfLiquify);

function swapTokensForEth(uint256 tokenAmount) private {
    // generate the uniswap pair path of token -> weth
    address[] memory path = new address[](2);
    path[0] = address(this);
    path[1] = uniswapV2Router.WETH();

    _approve(address(this), address(uniswapV2Router), tokenAmount);

    // make the swap
        0, // accept any amount of ETH