Skip to content
CCPEDIAby Unity Nodes
App Development

Choice : Archive current contract

6 posts345 views7 likesLast activity Jul 2022

  1. prajwalhegde3OP

    Hi Everyone,

    I have been trying to create a choice where “signatory” party/s can exercise a choice on a specific contract to archive it.

    choice Archive_Contract : ()
          controller signatory
          do
            exercise [...] Archive
    

    I guess, I have to pass the current contractId instead of […]. Not sure if this is the right approach but I tried passing it as “this.ContractId” , but seems like its giving me a error.

    Can anyone help me with the correct syntax.

    Thank you!

  2. rikotacards 2

    A contract is archived by default once a choice is exercised. Assuming you don’t have the nonconsuming keyword in front of the choice, you don’t need to perform anything. You can just return (),

    more about nonconsuming here
    https://docs.daml.com/daml/reference/choices.html#non-consuming-choices

  3. prajwalhegde3 1

    Thank you @rikotacards

  4. cocreature 2

    Once you’ve changed it to a non-consuming choice, you can use self to get access to the contract id of the current contract.

  5. prajwalhegde3

    Thank you @cocreature

    I do have one more question though…

    As per the DAML documentation Archive choice is implicitly added to every template.

    Currently I have a Java GRPC method to invoke other choices defined in the template using the “CommandServiceGrpc” stub, so wanted to know if we can invoke this Archive choice from the same as well.

    Ref:
    https://docs.daml.com/daml/intro/4_Transformations.html#the-archive-choice

    Thank you!!

  6. cocreature 2

    The choice is implicitly added by the compiler. So in Daml-LF it always exists and it’s available over the ledger API. The Java codegen should generate it for you like any other choice. If you don’t use the codegen, just call the choice called Archive.