September 6, 2023 at 8:56 am #13093MyCoinAParticipant
I’m a little bit confused with gas setting.
Please check the attachments.
1. What is Amount plus fee and where to set it up?
2. I have chosen ‘Safe gas price’ at backend. For example, ‘Withdrawal fee’ values at $0.3, gas fee values at $0.1, where will the rest $0.2 go?
Attachments:You must be logged in to view attached files.September 7, 2023 at 10:20 am #13097alexgKeymaster
1. The “amount+fee” field is simply the withdrawal amount requested by the user, plus the withdrawal fee that will be charged to the user.
In this case, the user will receive 1 BNB to the address they provide, and 1.001 BNB will be subtracted from their balance. The 0.001 BNB will be used by CoinPayments to cover the miner fee, plus any remaining fees that they keep for their platform.
You cannot directly control “amount+fee”. Instead the user sets the amount, and the admin sets the fee. You can find the withdrawal fee when you go to the admin page for the BNB Currency:
“Currencies” -> “BNB Coin (BSC Chain)” -> Edit -> “Fees” -> “Withdrawal fee”.
In the case of the CoinPayments adapter, if you set the withdrawal fee too low, it will be set to the minimum allowed by CoinPayments, in this case 0.001.
For example, if you were to set the withdrawal fee to 0.0005, it would be reset to 0.001 by the adapter’s cron job.
On the other hand, if you were to set the withdrawal fee to 0.002, then CoinPayments will still charge your hot wallet balance 0.001 for the withdrawal, but your user balance would be charged 0.002 for the withdrawal. The remaining 0.001 would stay in your hot wallet but would not be counted towards the user’s balance, so it would be effectively yours. Note that the hot wallet balance is an asset to you in accounting terms, while the user balance is a liability to you.
2. Gas management with CoinPayments is a very unfortunate development. I have tried to make this as easy as possible, but it’s still clunky. Let me explain.
There are currencies that are native to their blockchain (Bitcoin, Ethereum, BNB, Tron, etc) and tokens, which are usually implemented on top of blockchains as smart contracts (ERC-20, BRC-20, etc).
At first CoinPayments was useful for easily providing multiple currencies to the plugin, such as Litecoin, Dogecoin, etc. Then tokens became popular and things changed.
When a user deposits a token to CoinPayments, the CoinPayments platform creates a new address (account in Ethereum lingo). The token is added to that account, and the plugin is notified to update its local balance.
When CoinPayments is asked to withdraw a token from that address, gas must be paid. Gas can only be paid from the blockchain’s native currency (e.g. Ethereum), not from other tokens. For example, if you request to withdraw some USDT.ERC20, some ethereum must exist to convert to gas. The CoinPayments platform requires that at least 0.02 ETH exist on that specific address, not just in your CP account, for the withdrawal to proceed. This is because when this was programmed, 0.02 ETH was a reasonable fee to pay for transferring a token (today it’s about 32 USD which is too much). The CoinPayments platform requires this whether you request a withdrawal via the API, or directly via their admin pages. Go ahead and try it, you will receive a message to that effect.
Once this happened, I implemented the following solution:
For each token, the admin provides the contract address. The admin can also provide an etherscan and bnbscan API key to read the main currency balance for each address. If an address does not have enough of the native currency to allow for withdrawal of its tokens, then the wallet adapter’s cron job will transfer some of that currency to that address. This way, withdrawals can proceed. You can monitor the status of each deposit address when you go and edit an address via the admin screens.
For example, let’s say you deposit 20 USDT.ERC20 to address 0xABCD. The plugin will use the etherscan API key you provided, to check the Ethereum balance of that address, and see that it is 0. It will then transfer 0.02 ETH to that address. Then, if the user requests a withdrawal of some USDT.ERC20, that withdrawal can proceed. Today, a token transfer will cost a lot less than 0.02 ETH, so most of the ETH will remain on that address, and will still be in your account. As an admin, you can go edit the deposit address 0xABCD and at the bottom of the page, you will see in a metabox, whether any funds on that address are ready to be withdrawn or not. The plugin will show you the balance of the native currency available on that address, and whether there’s anything stopping the user from requesting a withdrawal of the token on this address.
Of course, this process is clunky and cumbersome. But I can’t think of any other solution given the situation. This is why I strongly recommend that the plugin is useful mostly for connecting to full node wallets (Bitcoin, Litecoin, Dogecoin, Monero, Bitcoin Lightning, etc). The CoinPayments adapter is less useful because of this CoinPayments limitation.
In any case, if you set things up correctly, it should work OK for Ethereum and BSC. Gas management on Tron and other chains is not supported.
If you want to learn more about gas management, you can check the CoinPayments adapter’s documentation, at:
- “Wallets Admin Docs” -> “wallets-cp” -> “Installation instructions” -> “Configuring gas management”
- “Wallets Admin Docs” -> “wallets-cp” -> “Troubleshooting” -> “Troubleshooting common issues” -> “Cannot withdraw any tokens (gas management issues)”
To answer your question, if the token’s withdrawal fee is set as $0.3 under the Currency entry (it would not be set in dollars but in the native currency), and the actual gas fee was $0.1 (again, this would not be in dollars), then the remaining $0.02 would stay with your site. Since the hot wallet balance would decrease by only 0.1 but the user balance (a liability to you) would decrease by $0.3, that’s $0.2 that your site gains.
If you are unsure about the difference between the hot wallet balance and the user balances, check the glossary section of the documentation or ask me. The hot wallet balance is the online funds, while the user balances are the funds that your site owes to the users.
Hope this has answered your questions, please let me know if not, or if you have more questions.
AlexSeptember 8, 2023 at 2:00 pm #13100MyCoinAParticipant
Hi Alex, really appreciate your support!
Thanks for your answer and I’m clear now!
Just for your information, I finally made up my solution after checking several service providers and a lot of famous coins/tokens.
bnb.bsc is the only best option.
your coinpayments adapter – users can generate their own bnb.bsc addresses to receive bnb.
swipelux.com – users can buy bnb.bsc via credit/debit card.
localcoinswap.com – buy and sell bnb.bsc via local currency without KYC. It means users can get bnb.bsc straightforwardly.
Looks like bnb.bsc is the only token which can be used as native one, its gas fee is also using bnb.bsc. And bnb.bsc has fast transaction speed(within 2mins) and very low transaction fee(0.001bnb about value of 0.2usd).September 11, 2023 at 6:17 am #13104alexgKeymaster
Thank you very much for taking the time to post this info.
Hopefully it will be useful to others.
- You must be logged in to reply to this topic.