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);
    sendBNBToCharity(portionForFees);
    
    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
    uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
        tokenAmount,
        0, // accept any amount of ETH
        path,
        address(this),
        block.timestamp
    );
}

Hey,
I have tried to fork yummy on both the testnet, and the mainnet. However, I can see the tokens that are being collected for the charity wallet accumulate in the balance of my contract, but after the threshold of: uint256 private numTokensSellToAddToLiquidity = 300000000 * 101 * 109;
has been reached, the tokens are not swapped for BNB and remain in the contract instead of being sent to the charity wallet.

Do you have any idea how to solve this issue?

Also, Im not sure if tokens are automatically added to the liquidity pool. I do see the balance of the tokenholders change after I trade in the test router and V2 router of pancakeswap.

Cheers1

it is normal. That number represents the amount to swap for BNB to send to liquidity and marketing

Yes, but the tokens arent swapped for BNB when I deploy an exact copy of yummy coin. If I call the amount of tokens stored in the contract it keeps going up when transacting, instead of being liquified after the threshold is reached

did you enabled swapandliquify?

1 Like

swapandliquifies, default setting is true (which I thought was required) so I didnt do anything with it

image

I solved it! the default option is enabled, however I needed to turn it off and then turn it on again so now it works. Thanks for your clue!

1 Like