0

Imagine that my privacy conscious wallet always creates a new child address to receive tokens. And imagine I was sent 2 USDC from Alice and 2 USDC from Bob.

My mental model is that the USDC token contract has a mapping of these two balances, but does not (and cannot) know they both relate to a single wallet and come from the same seed.

When I come to send 4 USDC to Carol, how many transactions are needed, what functions are called, and what address (or array of bytes) is used to sign the transactions?

The msg.sender is derived from the transaction signer, so I assume common wallet apps check the distribution of funds and create n transactions each signed by the private keys of the child addresses until the total is fully composed.

If this is the case (many transactions), if I've received many tiny payments into many new addresses, then emptying (or consolidating) my balance would required a lot of gas, no?

2 Answers 2

1

Any transaction must be signed by the private key associated with the public key of the holding account. In Ethereum it is not possible to create a single transaction with multiple inputs without using a smart contract. So for your example you would need to either Send 2 transactions of 2USDC each signed by the holding account. Or, what many exchanges who control a large number of addresses do is a process called 'sweeping' where they will move all of the funds to a single 'pool' address so that they can send a single transaction of an appropriate size(in your case 4USDC). As you can imagine, it is not optimal for a withdrawal from an exchange to be comprised of multiple transactions.

I think/hope I answered what you are asking, but feel free to follow up if not.

1
  • 1
    Thank you. I'd been interrogating a few LLMs on this question and they all seem to get it wrong, gaslighting me on a magical single transaction, against my knowledge of how it actually works. The sweeping is a great point, too. Commented Jan 9 at 16:12
0

When sending 4 USDC to Carol from multiple child addresses, your wallet will need to create multiple transactions, each signed with the private key of the respective child address holding the USDC.

For ERC-20 tokens like USDC:

Transactions Needed: One for each child address with USDC (two in your case, from Alice and Bob).

Function Called: Typically transfer or similar in the USDC contract.

Signing Address: Each transaction is signed by the private key corresponding to the child address holding the USDC.

In scenarios with many small balances across different addresses, consolidating funds can become gas-intensive due to the need for multiple transactions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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