Lost AccountAddress - Standalone

I read that kmd supports account recovery with a mnemonic. Is the same possible in standalone?
If we lose an account address in case of standalone, is it lost forever?

PS: I’m using Algo’s Golang v2 SDK

All stand alone accounts have a mnemonic backup phrase. You just need to record it somewhere when you create the account.
https://developer.algorand.org/docs/features/accounts/create/#how-to-generate-a-standalone-account

1 Like

Thanks @JasonW
Is there any example that shows how to recover a standalone account from a mnemonic?

We recover standalone accounts in many examples. On the github readme for the JS SDK shows an example of how to do this: https://github.com/algorand/js-algorand-sdk#mnemonic-to-secret-sey

For go, https://github.com/algorand/go-algorand-sdk/blob/develop/crypto/crypto.go#L45 (GenerateAddressFromSK) is the closest I could find. However, this is not part of the latest release.

Does Go SDK have a wrapper for this? I’m looking at https://pkg.go.dev/github.com/algorand/go-algorand-sdk@v1.4.2/crypto?tab=doc

You can already do it with the current SDK. See https://developer.algorand.org/docs/features/transactions/offline_transactions/, full example at the bottom, function recoverAccount.

Documentation: https://pkg.go.dev/github.com/algorand/go-algorand-sdk@v1.4.2/mnemonic?tab=doc#ToPrivateKey

Thank you @fabrice. I think recoverAccount() deserves to be made an exported function in the SDK.

Is v2 algod client stable and complete? Should I use v1 or v2 client? Please suggest.

Please use the v2 client. (v1 is deprecated)

1 Like

Thanks @ryanRfox. Does v2 client support MakeClientWithHeaders()? I need to use purestake service which requires a custom authn header to be passed.

I believe this is a known issue and is being worked on. V1 will be around for at least 6 months, so you can continue to use it until this fix is in.

1 Like

Thanks @JasonW.

For now, I just vendored in the packages and changed the header key at https://github.com/algorand/go-algorand-sdk/blob/develop/client/v2/algod/algod.go#L9 to my choice. I just did a transaction on test-net and it worked with v2 client.

I worked around it like this for the v2 indexer api (using purestake)

commonClient, err := common.MakeClientWithHeaders("https://mainnet-algorand.api.purestake.io/idx2", "X-API-Key", apiKey, []*common.Header{})
if err != nil {
	return nil, fmt.Errorf("error creating indexer client to purestake: %w", err)
}
client = (*indexer.Client)(commonClient)
1 Like