How to add deposit and withdraw BNB functions to my BEP20 smart contract

I used this template https://github.com/spartan-protocol/bsc-contract-templates/blob/master/contracts/BEP20Mintable.sol
For my contract and when I deployed it I can send BNB To it or withdraw so if I want to add this functions how can I add it

1 Like

I am not familiar with bsc-chain, if you want to get a better help, maybe you can ask at their forum.

Your template is similar with an ERC-20 token on the Ethereum, so it can not deposit and withdraw, if you want to achieve these functions, you had got to write them by yourself.

1 Like

Hi @Haithem,

Welcome to the community :wave:

As @skyge said, anything specific for BSC you can try asking in their community: https://community.binance.org/category/44/en-binance-smart-chain

I wasn’t sure why you wanted to deposit and withdraw BNB from your fungible token. It is best to keep the token as simple as possible and have any selling functionality in a separate contract.

1 Like

Did you solve your problem?

I didn't understand very well what you need.
Btw to be able to receive BNB you have to add a fallback function like this:
receive() external payable{}

While to be able to withdraw them, use this:

function rescueBNB(uint256 amount) external onlyOwner{
    payable(msg.sender).transfer(amount);
}
1 Like

please how do i interact with the rescueBNB function in python web3?