HOWTO: Emergency withdrawal from BenSwap

3 503
Avatar for norphine
2 years ago
Topics: Defi, Bitcoincash

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:


  1. Copy the whole MasterBreeder.sol contract:

  2. Open Remix in a new tab:

  3. Once in Remix, click on "New file", name it "MasterBreeder" and paste the contract you copied in step 1.

  1. 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

  1. 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!

  2. 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

  1. 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.

  2. 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".

  1. 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.

  1. 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.

  1. 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.

$ 39.02
$ 22.12 from Anonymous user(s)
$ 12.03 from @TheRandomRewarder
$ 2.00 from @molecular
+ 6
Avatar for norphine
2 years ago
Topics: Defi, Bitcoincash


This is one of the most helpful tip so far ( for rugged pull by beachswap )

Thanks anyways 💓😊

$ 0.00
2 years ago

What about the phone users?

$ 0.00
2 years ago

I'd say this is essential to know. Read and bookmarked for such emergencies. Thanks for sharing. Hope we'll never need to use it.

$ 0.00
2 years ago