BSC contract - Developer

Who wants to help me with creating a new bsc contract?

PM me

Hello

Send email to

devsolidity@gmail.com

HiI sent you a PM check

Hello there. i have a question:

The swapAndLiquify function converts half of the contractTokenBalance tokens to BNB. The other half of tokens and part of the converted BNB are deposited into the tokens BNB pool on pancakeswap as liquidity. For every swapAndLiquify function call, a small amount of BNB leftover in the contract. This is because the price of the token drops after swapping the first half of the tokens into BNBs, and the other half of the tokens require less than the converted BNB to be paired with it when adding liquidity. The contract doesn’t appear to provide a way to withdraw those BNB, and they will be locked in the contract forever.

How can we fix this?

i would be more tha happy to chat on telegram: @Covalent5 too =)

Many thanks in advance.

You can add a function to withdraw the contract balance. Try this:

function withdraw() public onlyOwner {
msg.sender.transfer(address(this).balance);
}

1 Like

Hey thanks for the swift reply. Also, i am trying some of your contracts from github (awsome job by the way) and when i try to deploy on testnet at remix i get:

Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
execution reverted

Any ideas?

Can you show your code? Maybe paste on pastebin and share link or just send here but formatted please.

https://pastebin.com/PPfsK3CU Thank you so much =)

Well you must change router address dor testnet.

From this: 0x10ED43C718714eb63d5aA57B78B54704E256024E
to this: 0xD99D1c33F9fC3444f8101754aBC46c52416550D1

I changed it but i still get it =/ No errors on compiling.

show your remix page please. Also try to clean remix cache and cookies

You are not on BSC testnet. You are on ropsten wich is EThereum

1 Like

Oh right. Ill reconfigure Metamask and let you know. Thanks =)

It worked. Thank you bro!

1 Like

please confirm my answer as solution

1 Like

how do i do that???

Also, why if i switch to solidity 0.8.0 it gives an error for your withdraw function?

TypeError: “send” and “transfer” are only available for objects of type “address payable”, not “address”. → PowerCoin.sol:1095:9: | 1095 | msg.sender.transfer(address(this).balance); | ^^^^^^^^^^^^^^^^^^^

different solidity version = differnet syntax

Oh man, i have a lot to learn =) thank you buddy! I really appreciate your help. I don’t think can mark any solutions as i didn’t start this thread, right?

1 Like