0

With Solana, there is the possibility to get accounts which obviously depend on the wallet. This can be done using the wallets GetAccount(index) function, e.g. with

   Account fromAccount = wallet.Account;
   Account toAccount = wallet.GetAccount(42);

(BTW, I used Solnet with C# for doing some tests, but probably this getaccount functionality is also available in the cli or the json rpc, I didn't check this so far)

I'm totally confused for what this is good for? E.g. in Phantom there is only the wallet account used. When minting, I can use arbitrary accounts. On the other hand there are mechanisms like PDA and ATA.

I'm wondering:

  • when minting shall I create several wallets and use the wallet account instead? But then, how can I transfer the tokens to the ATAs from the InitialAccount to some ATAs?
  • the Phantom wallet only shows or supports the wallet account (=pubkey), there is no (at least I found no) possibility to use these "depending" accounts mentioned above. Credits, which are on depending accounts are not shown (thankfully I'm using the devnet only so far).
  • shall I use these wallet.GetAccount(...) function at all?
  • what can I do with this?

Please enlighten me ;-) Thanks in advance!

1
  • P.S.: I know that with GetAccount(index) I can get the accounts on the wallet's ed25519 elliptic curve. But this doesn't help to find out the purpose of using them.
    – HansHeinz
    Commented Mar 2 at 12:41

1 Answer 1

1

The best is to "use the source!" If we look at GetAccount at https://github.com/bmresearch/Solnet/blob/4f85baccdb81b51b0a650b3625a58b3921916a8c/src/Solnet.Wallet/Wallet.cs#L166, we see:

        /// <summary>
        /// Gets the account at the passed index using the ed25519 bip32 derivation path.
        /// </summary>
        /// <param name="index">The index of the account.</param>
        /// <returns>The account.</returns>

So as you point out in your comment, this is just giving a new address by changing the derivation path for the key. You can think of it as a sub-account, just like sub-accounts in any BIP-44 derivation path.

This is only a Solnet thing, and not easily exposed to users in most tools, and not part of the JSON RPC spec, since that doesn't care about derivation paths. The Solana CLI only exposes it via commands like:

solana-keygen pubkey prompt://?full-path=m/44/2017/0/1

Since it's not common, I would avoid using it unless your users absolutely want sub-accounts.

1
  • Wow! This makes sense and answers my questions. Thanks a lot!
    – HansHeinz
    Commented Mar 5 at 14:04

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.