Contract keys

lets say i have created a contract from a template and that contract is referenced via key

after some time i excersised another choice which led to archive and create a new contract

Now, on reference with the keys will i get the data from actual archived contract or the active contract???

Please clarify!!!

Since individual contracts are immutable but things change, contract keys are a way of keeping a reference to some state that changes over time, related to the entity that is covered by that key. With this being caveated by future developments with regards to keys in multi-domain environment (see our docs here), one key can be associated with one contract at any point in time. If you exercise a choice by key and this choice leads to the contract being archived, trying to fetch or exercise by key again won’t work. If you also create a new contract associated with that key (e.g. a bank account associated with a specific user receives some transfer of funds: the entity to which the key is related would be the same, but the actual immutable contract tied to that key is the same), fetching or exercising by key will lead to that new contract being acted on, with its previous “incarnation” not being involved at all.

I hope this helps. For further details, you can see this kind of thinking in our documentation here and here.

2 Likes

Thank you Stefan