0

I am creating one app with functionality to import Ethereum chain wallets and solana wallets with keywords and PrivateKey.

For Ethereum chains, i successfully imported the wallet using entered Private Key. I want to do the same for Solana. I am creating Solana wallet address using https://github.com/ajamaica/Solana.kt this code's Account.kt class and also signing transactions and sending tokens using this. Can anyone help if is there any method to import Solana wallet using PrivateKey?

Hemangi
  • 11
  • 1

1 Answers1

0

In the default constructor for the Account.kt class, it's generating a new keypair for you to use. If you want to import an existing keypair, you can use any of the other constructors, such as:

The secret key or JSON string parameter is the 64 bytes representing your private key, like:

[131,30,15,126,65,195,177,39,147,196,183,221,159,85,134,0,29,179,48,175,149,133,13,75,184,212,99,68,29,62,82,248,37,183,235,40,42,249,238,136,159,202,239,211,121,108,51,154,178,214,31,6,111,28,202,173,100,41,145,230,76,152,208,131]

Note that Solana and Ethereum are not perfectly compatible since they use different cryptographic curves. Solana uses the ed25519 curve for its accounts / keypairs, so your private key will be 64 bytes, whereas Ethereum uses the secp256k1 curve, meaning 32 bytes for your private key.

Jon C
  • 7,019
  • 10
  • 17