If the "context" of a smart contract can see only the transaction where it sits and its inputs-outputs, how can a smart contract interact with other smart contracts living in different transactions?
-
Since everything is on the block chain, I find it hard to believe that a smart contract can only see a specific transaction? Maybe you can elaborate?– Ahmedie-mCommented May 1, 2021 at 5:07
-
@Ahmedie-mi it is true, on Cardano, smart contact can only consume the input transactions. It does work only with the UTXO set and does not keep the entire blockchain in memory.– Marek Mahut - StakeNutsCommented May 1, 2021 at 7:51
2 Answers
It can't.
But that doesn't mean different smart contracts can't interact. The interaction must simply happen in the same transaction.
As an example, imagine you have some Uniswap-like liquidity pool as one UTxO and another UTxO belonging to an auction contract. Then you can use the pool to swap tokens and then use the swapped tokens to bid in the auction, all in one transaction. That transaction will have both UTxO's as inputs (plus additional inputs for the funds that you swap) and updated UTxO's for both the liquidity pool and the auction as outputs.
You have to think differently when working with the EUTxO-model, but that model is at least as powerful as the accounting model used by Ethereum.
In simple words, it probably can't (even thought we do know the final Plutus design yet).
If two smart contacts needs to interact between each other, they need to provide each other inputs to consume, just like it would be the case with end-user.