Connecting a stateful and stateless smart contract

In order to connect a stateless to a stateful, I know I can check for the app_id of the stateful transaction and make sure the group size is 2. How does the stateful contract know about the stateless?

1 Like

Hi @javier0rosas

You can store the Smart Signature (Stateless ASC1) address as global variable in the Smart Contract. Take a look at this article to read more about the topic.

Remember that with the AVM 1.0 linking Stateless and Stateful components is no more needed! In fact, with the AVM 1.0, Applications have both an Application ID and an Application Address, so that you can issue transactions directly from the Smart Contract. So, for example, you can execute an Asset Transfer directly as Inner Transaction, without pairing the App with a Stateless ASC1.

2 Likes

A stateless smart contract (aka smart signature) can be used in two ways:

The recommended way is to use it as a contract account.
Then the stateful app just needs to check the sender of the stateless TEAL transaction: if the sender is equal to the contract account address and if the account was never rekeyed (which should be enforced by the smart signature), then you’re good.

EDIT: As mentioned by @cusma, use of stateless ASC1 / smart signatures is much more limited now with AVM 1.0. Most use cases can be handled by inner transactions.

1 Like