So in Plutus we have the Address type which has two constructors ScriptCredential which is a ValidatorHash or PubKeyCredential which is a PubKeyHash but all these are not encoded in the same way as addresses on the alonzo testnet or any other real net.

I'm using the script Alwayssucceed from the Alonzo-testnet repo.

When we compile it to .plutus and build its address in cli we get addr_test1wpnlxv2xv9a9ucvnvzqakwepzl9ltx7jzgm53av2e9ncv4sysemm8

But in Plutus if we display its Address we get a totally different output. This is what I tried because Cardano addresses are encoded in bech32.

import Data.ByteString.Base16 as B16
import Codec.Binary.Bech32 as B32

valhash :: Maybe Plutus.ValidatorHash
valhash = toValidatorHash $ scriptAddress validator

transform :: IO ()
transform = let Right prefix = humanReadablePartFromText "addr_test1" in
  case valhash of
    Nothing -> print @String "Nothing"
    Just vhash -> case vhash of
      Plutus.ValidatorHash vhashbs -> print $ B32.encode prefix (dataPartFromBytes $ fromBuiltin vhashbs)

Output : addr_test11xpnaff4z2xn3szgf8z6a2txju6dnsmsar22h2fnmvf7hyx8lpvw

Someone suggested here that in Plutus these Addresses are encoded in Base16, but B16.decode $ fromBuiltin vhashbs returns that it isn't a Base16 encoded bytestring.

My question is, is there a way to convert Plutus addresses to real Cardano addresses? Or will they understand each other when off-chain support (PAB) comes to real blockchains?


  • Have you managed to solve this? Nov 4, 2021 at 19:18
  • I think the question does not make much sense actually, we can convert from .plutus to bech32 and that's enough, I think when you convert to Address you put it in the format for the Emulator, it is not linked to real net, but honestly I don't know. Currently I'm looking at how to get the right ValidatorHash from the validator, still no clue. This conversion process is very unclear (what format does plutus understand, what format is to be passed on the blockchain...) Nov 18, 2021 at 14:18


Your Answer

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

Browse other questions tagged or ask your own question.