HOWTO: Manage fees (gas) on CoinPayments ERC-20 token deposit addresses

How to manage payment of Ethereum gas fees for ERC-20 tokens.

There is a serious issue related to ERC-20 tokens on CoinPayments that has since remained undetected.

This issue would prevent withdrawals of tokens based on the ERC-20 standard. Examples of these tokens currently are:

Token nameCoinPayments symbol
BNB Coin (ERC-20)BNB.ERC20
Binance USD (ERC20)BUSD
POA20 (ERC20 Token)POA20
SparkPoint (ERC20)SRK.ERC20
Tether USD (ERC20)USDT.ERC20

The problem

When a user is assigned a deposit address (“account” in Ethereum parlance) for an ERC-20 token, this address will contain the token that the user deposits. However, in order to be able, at a later time, to move that token to a different address, there must also be Ether on that address, to pay for the gas fees. Such is the case where a user requests a withdrawal, because the token must be transferred to a new address (account) and gas must be paid.

Even if there is plenty of Ether in your CoinPayments account, the platform cannot use it to pay for gas fees and transact, unless the Ether is on that same address. You can test this yourself. Even if you attempt to withdraw an ERC-20 token via the CoinPayments platform, circumventing the plugin and its ledger, you will see the following message (the example is for USDT.ERC20, but the same applies for other ERC-20 tokens):

Important: You must have 0.02 ETH in the same address as your USDT.ERC20 in order to pay the gas to send it. Not just in your account balance but in the same address; if needed you can do a withdrawal of ETH to your USDT.ERC20 address.

This is fine to do manually for one address, but within the context of this plugin, there may be multiple users with many deposit addresses, and thus the process of sending Ether to ERC-20 deposit addresses must be automated.

Since version 1.2.0, the CoinPayments adapter introduces a cron job that will auto-transfer small amounts of Ether to such ERC-20 deposit addresses (deposit addresses with non-zero balance), so that gas can be paid. In actuality, much less than 0.02 Ether is paid per transaction, but this depends on network conditions.

The cost of the Ether for withdrawals must be covered by the withdrawal fees that the users pay to you, otherwise the transactions will cost you money.

The solution

  1. Install the CoinPayments adapter version 1.2.0 or later. This version introduces a new ERC-20 gas management feature to address this problem.
  2. Go to the new WalletsCoinPaymentsERC-20 gas management tab.
  3. Enter an API key. Etherscan is needed for the plugin to be able to check the token and Ether balances for these deposit addresses that are controlled by CoinPayments.
  4. Review the settings in the table. For each ERC-20 token that you have enabled on your site, you must set:
    • The contract address. This is a hex string beginning with 0x. For some tokens, this may have been filled in for you.
    • How much of that token must be deposited to the deposit address before the plugin starts moving Ethereum to that address. A non-zero amount is a good idea here (default: 0.01). We don’t want to be sending Ethereum to addresses that will never be used to deposit funds. This Ethereum is unrecoverable for other purposes than paying for gas.
    • How much Ether balance the plugin should aim to keep on each such address. The recommended amount by CoinPayments is 0.02 ETH, but you may be able to get away with less than that, depending on network conditions. Hopefully, as scaling solutions are being rolled out on Ethereum, these fees will soon become less pricey.
  5. Deposit Ethereum to your CoinPayments account. To do this efficiently, you can use your personal Ether deposit address, available at:

If you want to be notified, every time such an Ethereum transfer occurs, you can enter you email under the WalletsCoinPaymentsDebuggin’ tab. You will be emailed every time such a transfer succeeds or fails.


Understand that this is a highly complex algorithm that I had to develop in short notice (and thus further delay the upcoming release of wallets6). Moreover, due to the currently high network fees, it is impossible to test the operation of the algorithm at scale. If you spot issues with this, please post at the support forum below. Thank you!


The support forum for the CoinPayments adapter is here.

If you are not sure why you have to do this or if you have any other questions, please post on the forum, or contact me.


  1. PERFECT Solution!
    In my project I have disabled all erc20 coins – just because it is terrible (Vitalik sleeping on…), but please create the same way for BEP20 / PEP2 coins in Conpayments (and maybe in V6 full node for BEP20)

    1. Ah yes, it’s probably best to not use the ERC-20 coins available on CoinPayments, due to Ethereum’s currently high fees. I cannot imagine the Ethereum foundation not solving this issue soon.

      To be honest, right now I’m focused on the upcoming release, and then I want to look into ERC-20 again, because at some point in the future, Ethereum is likely to scale. Also Bitcoin lightning is a necessity at this point. The solution to Ethereum scaling may come only after a few months, and developing a solution for lightning wallets will also take me a few months, so by the time I’m finished with my current backlog, I will evaluate again what I should be doing first.

      BEP20 is a good idea, I want to do something with it, but is currently low on my list, because I personally think the Binance chain is a fad: It only has utility as long as Ethereum still has high fees. Otherwise, as far as I understand, it’s essentially a centralized blockchain owned by one company. Doesn’t sound very future-proof to me. We’ll see.

      with regards

Leave a Reply

Your email address will not be published. Required fields are marked *