I need a bech32
wallet address and all that I have is my wallet PKH
and a wallet Id
. Is there a way to derive that bech32
address in python?
Needed to perform queries on blockfrost and find how much amount of ADA I have in my wallet.
Cardano Stack Exchange is a question and answer site for users and developers of the Cardano cryptocurrency ecosystem. It only takes a minute to sign up.
Sign up to join this communityYou can use pycardano to derive the address from a public key file.
Example:
from pycardano import Key, Address, Network
pk = Key.load("/path/to/payment.vkey")
pkh = pk.hash()
addr = Address(payment_part=pkh, Network.MAINNET)
print(addr)
If you already have the public key hash, use the following code to get pkh:
from pycardano import VerificationKeyHash
pkh = VerificationKeyHash(bytes.fromhex("1234abcd..."))
You can learn more about key and address manipulations in this page: https://pycardano.readthedocs.io/en/latest/guides/address.html