3

I can get public key from wallet adapter, so how to convert it to address in Solana ?

3
  • I'm confused. The public key is the address. Do you mean base 58 representation of the public key?
    – sohrab
    Commented Oct 10, 2022 at 21:35
  • 1
    Yeah, Public Key it self is the address. If you want base58 representation use .toString() method. Commented Oct 11, 2022 at 11:15
  • Is my answer below what you needed, @Fatur? If so, click that ‘accept’ checkmark, when you have a chance. Commented Nov 14 at 17:33

1 Answer 1

2

The terms ‘public key’ and ‘address’ are interchangeable. The public key of a wallet is the wallet’s address.

At a fundamental level, the address is a 256-bit number. In practice you see addresses encoded in various formats, like base58 or base64.

Given a PublicKey object from @solana/wallet-adapter you can obtain its base58 representation like this:

const base58Pubkey = publicKey.toBase58();

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.