3

I would like to understand how one can reference an external plutus script in one transaction. In solidity (for the other script), one can import the contract interface into their script, create an object using the smart contract address and then call the visible functions of the other script (as below).

address token = 0xE592427A0AEce92De3Edee1F18E0157C05861564;
IERC20(token).totalSupply();

I presume to achieve a similar effect in plutus, you would need to perform this all in the off-chain Contract code? And in order to do all of this you would need both the code for the other script as well as the address?

1 Answer 1

3

Reference Scripts, the ability for a transaction to reference scripts from a prior transaction is scheduled to be available later this year, sometime in June I believe. https://github.com/cardano-foundation/CIPs/pull/161

However, I'm not sure this will be what you're looking for. In Solidity, smart contracts are like recipes: do X, then do Y, and then do Z. On Cardano, a validator (smart contract) is a function that return a boolean representing whether the provided transaction may spend the funds may, yes or no?

Because of this difference, contract composition will look different. Composability on Solidity resembles a micro service architecture, each service (contract) can synchronously call other services (contracts) via an exposed api. Composability on Cardano, on the other hand, will more closely resemble an event driven ecosystem (or FRP). Services will emit events that can be consumed to trigger downstream events.

2
  • 1
    Thanks for the response Matt! So let's say (in the current cardano environment), one of the parameters to my validator function is the total supply of a native asset, are you saying that it is not possible to query the total supply of this native asset from it's policy script? Apologies if my initial question was not quite clear.
    – Zlac116
    Commented Feb 13, 2022 at 16:01
  • Composability on Cardano, on the other hand, will more closely resemble an event driven ecosystem Can you please elaborate? Commented Dec 16, 2022 at 23:39

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.