How to get PubKeyHash of an address without vkey?

How to get Address -> PubKeyHash without vkey just with addr like addr_test1wrf230u95zr26lut09mchmt82d235v6335jvszme2jevklslg5lfz?

It must be possible, because when you build unlocking transaction from smartcontract locked funds with cardano-cli transaction build ... you pass --change-address parameter which doesn’t require vkey like cardano-cli address key-hash command does. Smartcontract manages to get PubKeyHash from provided addr_… which it can get from txOutputs :: [txOut]

Hi there and welcome @Cony_Mony,

You are right that it is possible. There are tool out there that can do these things. The cli itself has no command line function to do this currently. But the functions do exists in the haskell code of the cardano node. A brilliant other forum user called @bwbush made a handy tool that does multiple things, like the thing you asked above. The tool is open source and uses the cardano-node Haskell libraries to get more usability. Here is the GitHub [1]. Given your above address and the following command

mantra info-address addr_test1wrf230u95zr26lut09mchmt82d235v6335jvszme2jevklslg5lfz

I get the output

Output Address: 
  "addr_test1wrf230u95zr26lut09mchmt82d235v6335jvszme2jevklslg5lfz"
  AddressShelley (ShelleyAddress Testnet (ScriptHashObj (ScriptHash "d2a8bf85a086ad7f8b79778bed6753551a33518d24c80b7954b2cb7e")) StakeRefNull)

Where the PubKeyHash corresponds to d2a8bf85a086ad7f8b79778bed6753551a33518d24c80b7954b2cb7e. Hope this helps.

1 Like

Thank you very much :pray:

1 Like

By any chance, do you know what these haskell functions are? I have tried looking into it, but got stuck as I am not very good at Haskell yet.
I have looked at cardano-node/cardano/api/src/Cardano/Api/Address.hs but all I could find there were these functions:

  • deserializeAddress :: AsType addr -> Text -> Maybe addr
  • deserializeFromBech32

Not sure if these are the ones which I really need.

I think this video will help :slight_smile:

2 Likes