On Ethereum, for example, there is a way to see the Solidity code that is deployed in a specific address (as long as the code gets verified).

Is there a way to achieve this same behaviour in Cardano?

1 Answer 1



I just realized I misunderstood your question, you are searching for a way to get the Plutus code starting from an address, not to get and address from your Plutus code!

I'm leaving the old answer below just in case it can help

Last answer

In Cardano, you need to include the serialized Plutus script in your transaction to interact with it so it is assumed you have/know the code of the smart contract you want to interact with

as soon the Vasil hard fork goes through you should be able to refer to the script from a previous transaction (this doesn't change the fact you know where your script is so you know where to get it)

so by protocol there should be nothing like that

however, if you go on sites like https://cardanoscan.io and search for a specific smart contract address you should be able to see on the bottom of the page two tabs: Transactions and Script

the script is visible only if the smart contract is verified there as in Ethereum

Old answer

using cardano-cli

once you have your serialized smart contract (which you can obtain as described in this other answer)

you can run

cardano-cli address build --$your_net --payment-script-file path/to/your-validator.plutus.json

where your-validator.plutus.json is the output of writeFileTextEnvelope in the answer cited above

this will print out the corresponding validator address

using PlutusTx

in the Ledger.Typed.Scripts module there is a validatorAddress function that is so defined:

validatorAddress :: TypedValidator a -> Address

once you have an Address you can use show on it in order to get a string, or if you want just print it to the standard output you can use print

NOTE: if you have an untyped Validator rather than a TypedValidator a, and you still want to use the PlutusTx way, you could use:

unsafeMkTypedValidator :: Validator -> TypedValidator Any

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.