anyone know how to do like a comtract clean up function that takes any eth or wrong tokenssent to the comtract and trades them out or withdraws?

Jan 9, 2022, 10:14 PM
// Used to withdraw any BNB which is in the contract address. BNB should never be in this address, so this will be used if someone accidentally
// transfers BNB to this address. This can be used to get them back their BNB.
function withdrawBNB(uint256 amount) public onlyOwner() {

if(address(this).balance == 0)
revert("Contract has a zero balance.");
else
{
if(amount == 0)
payable(owner()).transfer(address(this).balance);
else
payable(owner()).transfer(amount);
}
}

// Used to withdraw tokens transferred to this address. Used to prevent permanently locking tokens which are accidentally sent to the contract address.
// Contact the dev if you accidentally send tokens and we will do our test to return your funds.
function withdrawToken(address token, uint256 amount) public onlyOwner() {
require(amount > 0, "Invalid amount supplied.");
IBEP20(address(token)).transfer(msg.sender, amount);
}
Jan 9, 2022, 10:14 PM
👍
Jan 9, 2022, 10:15 PM
The code above is for the BSC chain, just change the IBEP20 bit to be IERC20
When allowing users to interact with my website what other wallets do i need to support besides Metamask?
Jan 9, 2022, 10:50 PM
The most common wallets are Metamask, trustwallet and Coinbase wallet (You can use WallectConnect to allow most of then and WallectLink to allow Coinbase wallet)
Jan 9, 2022, 10:51 PM
Ok thanks.
Are there any libraries that made supporting multiple wallets like Metamask and Trustwallet easier?
Jan 9, 2022, 11:10 PM
awesome! thanks
Jan 9, 2022, 11:53 PM
https://github.com/Web3Modal/web3modal
Jan 9, 2022, 11:53 PM

© 2024 Draquery.com All rights reserved.