1

I’m developing an exchange. When a new user register on website we will create new eth wallet for them. When they deposit USDT on their wallet how can I transfer that USDT amount to another address (pool) and pay gas fee with another account (because new user’s eth balance is 0)?

2

The most Ethereum friendly solution would be

  1. Create and deploy a controller smart contract. This co-ordinates that we have deterministic addresses for payment forwarded smart contracts.

  2. For each new deposit address deploy a payment forwarded smart contract using CREATE2 from depositor controller. You need deploy a batch of these smart contracts upfront and then assign them to the customers as they come in.

  1. The smart contract has only one function - forward deposited ETH and tokens to a hot wallet. The exchange fee wallet calls this function and the exchange pays the fees.

An overview of Coinbase merchant non-custodial architecture. An example forwarder contract. Other CREATE2 users are most of mobile smart contract based wallets that support "recover wallet by friends" and non-ETH fee markets e.g. Pillar, Gnosis, Argent.

Pros

  • Can handle ERC-20 transfer() transactions from centralised exchanges that do not support ERC-20 approve() and transferFrom() mechanism

  • Using CREATE2 EVM opcode, the contract can be retroactively deployed to a deterministic address where the user already sent the payment even if the deployer system is down for some reason

Cons

  • May use more gas (see CREATE2 gas cost stats)

  • Needs a centralised co-ordinator for allocating payment forwarder addresses

  • Extra gas cost for the merchant to deploy forwarded contract per user and then calling this contract to forward its contents ETH and tokens to a centrally managed wallet

Difference over plain Ethereum account forwarders

  • You do not need to top up plain Ethereum forwarding accounts with gas money, as gas for the forwarder contracts can be centrally paid

  • Non-custodial logic - even if the deployer private key is compromised the system as a whole is not compromised

  • Smart contract can interact with payment forwarder contracts

However plain Ethereum accounts with hierarchically deterministic private keys may work as well, as long as you figure out how to keep them topped up for gas money.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.