My mental model so you can put me on the right track:
- A HD wallet is a mathematical tree construct from a seed key.
- The idea being that new key pairs, and therefore Ethereum addresses, can be created for every new transaction, e.g. to receive money.
- I can presumably have USDC sent to one of these extended addresses.
- Presumably the USDC token updates its record of how much each address has and ends up with the extended address in its state of balances.
- I can transfer this USDC so long as I send a transaction to the network calling the appropriate USDC contract function and having signed it with the corresponding extended private key of the address from which I am spending/deducting balance and that code in Circle's ERC-20 contract checks this.
Questions arise from this:
- Does the HD wallet persist state about the tree structure it has created so far?
- Does a wallet have to query every single ERC-20 contract on the blockchain and ask for its balance for a given address to give me a total of how much is "in" my wallet?
- If I only have a backup of of the seed key, then how can it create the extended keys and addresses? How does it know if I created 1 or 1 million extended addresses?
- How then does a wallet app arrive at a total without producing every conceivable extended address and asking every ERC-20 token for its balance?
There are two solutions:
- The wallet apps persist state that also must be backed up.
- I have totally misunderstood something which has led to this faulty thinking.
Thanks!!
Update
I added an answer from GPT-4 which was much more full and interesting than the pretty bad single word answers I got from the community.
Even though I explained that it was from GPT-4, the post was removed citing that AI answers are discouraged (words: "discouraged", actions: banned) citing that AI is not good for technical stuff, even though we all use it and code with it.
Why not just discuss or correct the answer? I expect it wasn't wrong. And who cares where a bunch of text comes from? Whether it came from my mind or the weights and biases of a system far more knowledgable than me, who cares?
This is an example of why AI will destroy all Stack sites.
The group of people with sticks that go around bashing everyone and everything on here destroyed these sites years ago but no one had another choice.
Now we all have a choice, no one is going to use these Stack sites and risk being beaten down by the guards.
StackOverflow is the online equivalent of the Stanford Prisoner experiment.
If you downvote this or try to remove it, YOU killed StackOverflow, just like the parking wardens killed the high street, not Amazon.