0

I want to generate the address of solana by using python how could I do that?like in web3.py we create an ethereum account/address.

1 Answer 1

1

We can use Solana.py module , which provides the function to create a solana address using the keypair fucntion. Here is the reference https://michaelhly.github.io/solana-py/core/keypair/ link

6
  • I'm using this code and generates a pair and get the public key too but unable to decode the pvt key of the pair I'm not getting the pvt key of pair Sep 26, 2022 at 6:21
  • code is that import solana from solana.publickey import PublicKey from solana.keypair import Keypair def create_account(): acount = Keypair.generate() print("Public Key:",acount.public_key) print("Private Key:",acount.secret_key) create_account() Sep 26, 2022 at 6:22
  • To decode it use pypi.org/project/base58 library . Sep 26, 2022 at 6:45
  • I'm getting this in pvt key Private Key: b'\xd4r2\xacS<\x99:\xa3\xee\xc2\x94\x91\x95\xa8r\xd5r0\xaf\xa5\xb5#\xa6 N\xf0U\xbb\xa3\x8a!\xe0\x19\xcb\xdd\xd0ug\xf0CS\xbc[\xf1\xd0\x8c\xa2;\xc0\xc4\xf9o\xa8\x8a\x8f\x02\x7f\x15\x8d\x87\x14\xed\xd3' and I tried the base58 decoder but it was unable to decode it Sep 26, 2022 at 6:47
  • keypair = Keypair.generate() which will generate the keypair , now do this bytes(keypair.public_key).hex() that should return the public key . Same goes for secret key as well. Sep 26, 2022 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.