HOWTO: Emergency withdrawal from BenSwap
![Avatar for norphine](https://cdn.rcimg.net/norphine/avatar-3200a59de087356ba3869f8848cea14e.png?width=150)
Many of us asked the same question: what will happen to our funds if Benswap is down? Benswap has backup servers, but what if their down too? In Benswap docs, you can't find anything related to emergency withdrawal. Emergency withdrawal is often done in ETH or BSC using Metamask and MyEtherWallet, but MEW is not available for SmartBCH.
Don't worry: as long as any bug overseen in Benswap's audit has been exploited, your funds are safe. Follow these steps to withdrawal them:
STEPS TO FOLLOW TO RECOVER YOUR FUNDS
Copy the whole MasterBreeder.sol contract: https://github.com/BenTokenFinance/benswapbch-contracts/blob/master/Contracts/MasterBreeder.sol
Open Remix in a new tab: https://remix.ethereum.org/
Once in Remix, click on "New file", name it "MasterBreeder" and paste the contract you copied in step 1.
![](https://cdn.rcimg.net/norphine/b6aabb47/457dc6fe279e4091d47da671d4f2b082.png?width=300&quality=10&blur=20)
At the left column, you will find the "Solidity compiler" tab. Click on it. In the new panel, select from the droplist the compiler version 0.6.12. Now, click the button "Compile MasterBreeder.sol". You will see 2 warnings: ignore them
![](https://cdn.rcimg.net/norphine/b6aabb47/d4a3a4a97d0305732eaa312b8a07cb08.png?width=300&quality=10&blur=20)
Make sure you have SmartBCH selected on Metamask. If you have multiple accounts, select the account from you want to recover the funds. And don't forget: you need a little BCH on SmartBCH to claim your funds!
Again on Remix: select "Deploy and run transactions". In the environment droplist, select "Injected Web3". This allow us to interact with your Metamask account. Below, on the "Contract" droplist, select "MasterBreeder - MasterBreeder.sol". Next to "At address", there's a text box where you're going to paste the address where the contract is deployed in SmartBCH: 0xDEa721EFe7cBC0fCAb7C8d65c598b21B6373A2b6
![](https://cdn.rcimg.net/norphine/b6aabb47/f69ecd95815d75ff3af9bc89acb1a717.png?width=300&quality=10&blur=20)
Once the address is pasted on the text box, you can click the "At address" button". Click on it and a list of the functions available in the smart contract will appear. Let's recover the funds. In this guide I'll focus on the pools, let me do some research for the farms and I'll upgrade it.
The first thing to know is the total balance you have staked on the pool (if you want the quicker way and don't mind your rewards, see the bottom of this article and skip steps 8 and 9). So go to the end of the functions list, until you find "userInfo". This is the function which will tell you your total balance by filling 2 fields: the pool PID and your address. For the EBEN pool, PID is 1 and for the WBCH pool, PID is 2. Benswap dev needs to make the PIDs list public, it's very helpful for things like this. In this example, we find the total balance of our WBCH pool. Fill the PID field, fill the address field and click on "Call".
![](https://cdn.rcimg.net/norphine/b6aabb47/9f759b7a59691718e7931ef728be96e1.png?width=300&quality=10&blur=20)
Copy the amount and go upwards, where you'll find the payable functions of the smart contract (in orange). Of course, click on "Withdraw". Again, you need to fill 2 fields: PID and amount. So on PID, insert 1 or 2 (EBEN or WBCH) and in amount, paste your total balance. Of course, you can withdraw less if you wish. Click on transact.
![](https://cdn.rcimg.net/norphine/b6aabb47/a3fca0b5fa7fbcba510f899c376d4d14.png?width=300&quality=10&blur=20)
Metamask pops up. Remix suggest a gas fee of zero, which won't work. Edit the suggested gas fee: set gas limit to 229854 and gas price (GWEI) at 1,05.
![](https://cdn.rcimg.net/norphine/b6aabb47/b4aa31d7fe47d4563a7b9ed3eda26cbc.png?width=300&quality=10&blur=20)
Confirm the transaction. Congrats! You recovered your funds! If you don't see your tokens (EBEN, WBCH or whatever token they add on the future) make sure it's added as custom token on Metamask.
Bonus track: emergency withdrawal function
Maybe you have seen a function call "emergencyWithdrawal". This is a quicker way to withdrawal all your funds if you don't care about the rewards: you just need to insert the pool PID and click on transact.
Feel free to comment if you have any doubts or improved ways to do this.
![Avatar for norphine](https://cdn.rcimg.net/norphine/avatar-3200a59de087356ba3869f8848cea14e.png?width=150)
This is one of the most helpful tip so far ( for rugged pull by beachswap )
Thanks anyways 💓😊