How to retrieve staking credential hash using cardano serialization library and what is it? How does it differ from public key hash?

  • Needs some more details. Try searching for "staking credential" here and seeing how others have asked.
    – gRebel
    May 9, 2022 at 0:23
  • 1
    Try referring github.com/StricaHQ/typhonjs, it's a pure js library. It has many util functions which might be useful for you. May 9, 2022 at 4:01
  • I Can't find much info about it. I think it is address stake credential converted into key hash.
    – Rollin
    May 9, 2022 at 4:42
  • You should add more details in your question, provide more context. May 9, 2022 at 5:24

1 Answer 1


You require an instance of type BaseAddress which you can get using a bech32 formatted address (addr_... or addr_test...). Here an example:

const bech32Addr = "addr_test1qpgljxnfw696g0zslw0p6y4z5qt3vdlxws3e5d2ghftrvgtt0t2lsj2wyyal9d5s5ga3204hzkzrsah9ndu2d7zvqezsl7shc6";
const addr = BaseAddress.from_address(Address.from_bech32(bech32Addr));

console.log(addr.stake_cred().to_keyhash()); // Ed25519KeyHash | undefined
console.log(addr.stake_cred().to_scripthash()); // ScriptHash | undefined

In regards to how they differ from PubKeyHashes: I recommend taking a look at the possible constructors for staking credentials which can be found here: https://playground.plutus.iohkdev.io/doc/haddock/plutus-ledger-api/html/Plutus-V1-Ledger-Credential.html#t:StakingCredential

Generally, if a staking credential was created using the Credential constructor which itself can be constructed using either PubKeyCredentials or ScriptCredentials you already see that staking credentials are not just pub key hashes. They could be validator hashes if a script manages staking actions for that address or even a staking pointer.

  • Thank you very much! That's what I needed. :)
    – Rollin
    May 12, 2022 at 18:23
  • I'd appreciate if you can mark my response as answer :)
    – Will
    May 13, 2022 at 8:46
  • Very helpful. Thank you!
    – caike
    Nov 22, 2022 at 21:48

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.