Save fees by withdrawing tokens from IDEX using its “escape hatch”

Iruwen
7 min readJan 27, 2019

Want to withdraw small amounts from IDEX at a minimum fee? Here’s how.

UPDATE 2020–10–20: After the launch of IDEX 2.0, this guide is probably obsolete - I didn’t check how exactly the new version works as I’m not using it myself. The instructions can still be followed to access the legacy IDEX 1.0 contract and withdraw funds from it if necessary.

IDEX is a semi-decentralized non-custodial exchange, so while it’s not a “true DEX”, you’re always in control of your assets, which is what most users care about. Tokens are deposited to an immutable smart contract, which has a so called “escape hatch” that can be used to withdraw them even if the centralized website normally used to interact with the contract goes down.

You can exploit that to withdraw tokens at a minimum fee paid in ETH. Normally withdrawal fees are deducted from the token you’re withdrawing, and since IDEX wants its withdrawals to be processed quickly, they’re taking a gas price as a basis that is a lot higher than Eth Gas Station’s “SafeLow” value. At the time of writing it was 4 Gwei vs 12 Gwei, but I’ve seen ratios up to 1:10.

The FAQ states that they “have a feature in the works that will allow users to lower the gas price of their withdrawals significantly”, but since that is not ready yet and the escape hatch is only mentioned briefly in their FAQ, I decided to write this guide on how to use it correctly.

There’s a constraint though: you have to wait until the so called “inactivity release period” is over to use this feature, meaning you’re not allowed to trade during that time. That period is 100,000 blocks, and at an average blocktime of 15 seconds that means 100000 / ((1 / 15) * 60 * 60 * 24) = ~17 days. Yeah, bummer.

If you prefer video guides, check out this one!

First of all you have to know a) what you want to withdraw, and b) how much of it. The “what” shouldn’t be too hard, just visit Etherscan and search for the token you want to withdraw. If you can’t find it, or if there are multiple results and you’re unsure which one is the right one, you can also look it up on CoinMarketCap and use the “Explorer” link, which should take you to the right token on Etherscan.

If you’re looking at this token for example, that link will take you here. You can be almost sure that it is the right token because it has a price and several links, including one to the official project site. You need the “Contract” address, which you’ll find in the upper right corner of the page (0xea38eaa3c86c8f9b751533ba2e562deb9acded40 in this example). If you move the mouse over it, a small copy icon should appear. You’ll find these copy icons in many places in Etherscan, which makes your life a lot easier.

We’ll come to the “how much to withdraw” part soon, but first you also need the IDEX contract address. You can search for “IDEX_1” on Etherscan, or visit IDEX and go to HELP > ETHERSCAN CONTRACT. The contract address is 0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208 at the time of writing.

Go to Read Contract on Etherscan. “9. inactivityReleasePeriod” shows you the current inactivity release period, which should be 100,000 blocks. You can check if you meet this requirement by entering your personal wallet address in “1. lastActiveTransaction” and clicking “Query”. The result should be lower than the last block minus 100,000.

Scroll down to “11. balanceOf”, insert the token contract address you figured out above into the “token (address)” field and your personal wallet address into the “user (address)” field. Click “Query” again and you’ll be presented with your IDEX balance below “balanceOf method Response” (in UINT256 format, which is just a specific way to format a number).

Keep the page open or copy both the token contract address and amount elsewhere, you’ll need this information later!

From here on, there are two possible ways to move forward: by utilising MyCrypto to interact with the contract, or since a recent update you can also initiate the required transaction directly from Etherscan, which is more convenient but still a beta feature. So far, it worked fine for me though.

Variant 1: visit MyCrypto, the Interact with Contracts page to be precise. Insert the IDEX contract address (see above) into the “Contract Address” field, and the “Contract ABI”, which you can find in the second box on Etherscan’s contract Code page, into the “ABI / JSON Interface” field.

Click “Access” and select “withdraw” (not “withdrawn”, unfortunately that function also exists) from the “Read / Write Contract” drowdown list. Now copy the token contract address from “token (address)” on Etherscan to the corresponding “token address” field on MyCrypto, and your balance from “balanceOf method Response” on Etherscan to “amount uint256” on MyCrypto. I’m assuming that you want to withdraw your whole balance here, otherwise you’d have to modify the UINT256 value to reflect the right amount.

Next access your wallet like you normally do (depending on what kind of wallet you’re using, e.g. MetaMask or Ledger). Don’t insert anything into the “Value” field, but set “Gas Price (gwei)” to some reasonable value; you have to decide what that means for yourself, but EthGasStation will surely be of great help here. If you set it too low, the transaction will take forever and eventually drop out of the mempool in the end. If you set it too high, you could as well just withdraw directly from IDEX 😉 You can keep the “Automatically Calculate Gas Limit” checkbox enabled, MyCrypto usually gets this right.

Now click “WRITE”, then “Generate Transaction” and finally “Send Transaction”. You’ll get a final chance to check that everything is correct. Please do so and then send and sign the transaction. The exact process might differ slightly for other authentication methods than MetaMask here, which is what I’ve been using.

Variant 2: visit Etherscan again, but this time go to Write Contract. Do this in a different tab, unless you copied the token contract address and amount we figured out on the “Read Contract” page earlier elsewhere. You should see a red dot and “Write Contract Connect to Web3”.

Click the link and establish the connection. I used MetaMask, not sure what else works here.

It has to be a Web3 provider which knows your IDEX wallet of course. If the connection was successful, the dot should have turned green. Etherscan will warn you that this is a beta feature, treat it as such. As I said before, it worked fine for me so far, but you never know.

Scroll down to “14. withdraw”, copy the token contract address from “token (address)” on the “Read Contract” page to the corresponding “token (address)” field here, and your balance from “balanceOf method Response” on the “Read Contract” page to “amount (uint256)” here. I’m assuming that you want to withdraw your whole balance, otherwise you’d have to modify the UINT256 value to reflect the right amount.

Now click “Write”, then you should get a final chance to check that everything is correct with whatever Web3 provider (wallet) you’re using. Please do so, especially make sure that you’re using a reasonable gas price for the transaction; you have to decide what that means for yourself, but EthGasStation will surely be of great help here. If you set it too low, the transaction will take forever and eventually drop out of the mempool in the end. If you set it too high, you could as well just withdraw directly from IDEX 😉 Then send and sign the transaction.

After the transaction has been processed (included in a block), you should see the tokens in your personal wallet. Note that if you check your balances on IDEX now, you’ll probably see the same amount of tokens both in your personal wallet and on IDEX. Don’t cheer and try to withdraw again, this is just a display issue (eventually because IDEX keeps track of its balances in an off-chain database for performance reasons). The values will either be corrected automatically after some time, or will do so as you try to withdraw again using the interface.

Congratulations, you have withdrawn your tokens at the lowest possible fee!

Here’s a very short rundown of what you need for future reference:

Preparation1. IDEX Contract Methods (Read):
https://etherscan.io/address/0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208#readContract
2. Use "balanceOf" Method:
> Insert the Token Contract Address
> Insert your User Wallet Address
3. Check reasonable Gas Price on https://ethgasstation.infoVariant 1 (MyCrypto)1. Interact with Contract:
https://mycrypto.com/contracts/interact
2. IDEX Contract Address:
0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208
3. IDEX Contract ABI:
https://etherscan.io/address/0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208#code
4. Read / Write Contract:
> Use "withdraw" Method
> Insert the Token Contract Address
> Insert the Token Amount (in UINT256)
5. Send Transaction with reasonable Gas PriceVariant 2 (Etherscan)1. IDEX Contract Methods (Write):
https://etherscan.io/address/0x2a0c0dbecc7e4d658f48e01e3fa353f44050c208#writeContract
2. Connect to Web3 Provider3. Use "withdraw" Method:
> Insert the Token Contract Address
> Insert the Token Amount (in UINT256)
4. Send Transaction with reasonable Gas Price

My Telegram username is @Iruwen, you can find me in CoinMarketCap’s great international community where we discuss general crypto topics. I’ll gladly try to help you out with technical questions of all sorts.

If you think this was helpful in any way, feel free to buy me a beer!

ETH: 0x0afAB9b6dA9FBb79f3260F71E4a17d4AF9AC1020
BTC: 16yAtsdjzEaQbH8ucK1nbtkqrpo791EZ7a

--

--