Skip to content
CCPEDIAby Unity Nodes
App Development

GRPC Api submit and wait for Archive choice

4 posts126 views5 likesLast activity Oct 2025

  1. David_MartinsOP 2

    Hello,

    We have an ongoing project targeting Daml 3.x and the canton network and have deployed an artifact into Devnet. Now we wanted to clear the ledger info for this package and we were attempting to run a Archive command via the GRPC api through the CommandService/SubmitAndWait endpoint with the following payload:

    Body Payload
    {
      "commands": {
        "command_id": "<command_id>",
        "commands": [
          {
            "exercise": {
              "template_id": {
                "package_id": "<package_id>",
                "module_name": "<module_name>",
                "entity_name": "<entity_name>"
              },
              "choice": "Archive",
              "choice_argument": {
                "unit": {}
              },
              "contract_id": "<contract_id>"
            }
          }
        ],
        "deduplication_duration": {},
        "act_as": [
          "<party_id>"
        ]
      }
    }
    

    But with this payload we are getting this error message:
    COMMAND_PREPROCESSING_FAILED(8,dd6a8889): mismatching type: DA.Internal.Template:Archive and value: ValueUnit

    Any assistance would be appreciated.

  2. WallaceKelly 1

    Here is a gRPC Ledger API request to archive a contract:

    com.daml.ledger.api.v2.CommandService.SubmitAndWait

    {
      "commands": {
        "act_as": [
          "{{appUserParty}}"
        ],
        "command_id": "command02",
        "commands": [
          {
            "exercise": {
              "template_id": {
                "package_id": "#AdminWorkflows",
                "module_name": "Canton.Internal.Ping",
                "entity_name": "Ping"
              },
              "contract_id": "{{contractId}}",
              "choice": "Archive",
              "choice_argument": {
                "record": {}
              }
            }
          }
        ]
      }
    }
    

    To confirm, you can use the following requests to create and query for a simple contract:

    create contract

    com.daml.ledger.api.v2.CommandService.SubmitAndWait

    {
      "commands": {
        "command_id": "command01",
        "act_as": [
          "{{appUserParty}}"
        ],
        "commands": [
          {
            "create": {
              "template_id": {
                "package_id": "#AdminWorkflows",
                "module_name": "Canton.Internal.Ping",
                "entity_name": "Ping"
              },
              "create_arguments": {
                "fields": [
                  {
                    "label": "id",
                    "value": {
                      "text": "testing"
                    }
                  },
                  {
                    "label": "initiator",
                    "value": {
                      "party": "{{appUserParty}}"
                    }
                  },
                  {
                    "label": "responder",
                    "value": {
                      "party": "{{appUserParty}}"
                    }
                  }
                ]
              }
            }
          }
        ]
      }
    }
    
    query by update-id

    com.daml.ledger.api.v2.UpdateService.GetUpdateById

    {
      "update_id": "{{updateId}}",
      "update_format": {
        "include_transactions": {
          "transaction_shape": "TRANSACTION_SHAPE_ACS_DELTA",
          "event_format": {
            "verbose": false,
            "filters_by_party": {
              "{{appUserParty}}": {
                "cumulative": [
                  {
                    "template_filter": {
                      "include_created_event_blob": false,
                      "template_id": {
                        "package_id": "#AdminWorkflows",
                        "module_name": "Canton.Internal.Ping",
                        "entity_name": "Ping"
                      }
                    }
                  }
                ]
              }
            }
          }
        }
      }
    }
    
    query acs

    com.daml.ledger.api.v2.StateService.GetActiveContracts

    {
      "verbose": false,
      "active_at_offset": {{ledgerEndOffset}},
      "filter": {
        "filters_by_party": {
          "{{appUserParty}}": {
            "cumulative": [
              {
                "template_filter": {
                  "include_created_event_blob": false,
                  "template_id": {
                    "package_id": "#AdminWorkflows",
                    "module_name": "Canton.Internal.Ping",
                    "entity_name": "Ping"
                  }
                }
              }
            ]
          }
        }
      }
    }
    

    These were created with the splice-node bundle 0.4.20.

  3. WallaceKelly 1

    As a point of comparison, here is a JSON Ledger API request to archive a contract:

    POST v2/commands/submit-and-wait

    {
      "commandId": "command02",
      "commands": [
        {
          "ExerciseCommand": {
            "templateId": "#AdminWorkflows:Canton.Internal.Ping:Ping",
            "contractId": "{{contractId}}",
            "choice": "Archive",
            "choiceArgument": {}
          }
        }
      ],
      "actAs": [
        "{{appUserParty}}"
      ]
    }
    

    To confirm, you can use the following requests to create and query for a simple contract:

    create contract

    POST v2/commands/submit-and-wait

    {
      "commandId": "command01",
      "commands": [
        {
          "CreateCommand": {
            "templateId": "#AdminWorkflows:Canton.Internal.Ping:Ping",
            "createArguments": {
              "id": "testing",
              "initiator": "{{appUserParty}}",
              "responder": "{{appUserParty}}"
            }
          }
        }
      ],
      "actAs": [
        "{{appUserParty}}"
      ]
    }
    
    query by update-id

    POST /v2/updates/update-by-id

    {
      "updateId": "{{updateId}}",
      "updateFormat": {
        "includeTransactions": {
          "transactionShape": "TRANSACTION_SHAPE_LEDGER_EFFECTS",
          "eventFormat": {
            "verbose": false,
            "filtersByParty": {
              "{{appUserParty}}": {
                "cumulative": [
                  {
                    "identifierFilter": {
                      "TemplateFilter": {
                        "value": {
                          "includeCreatedEventBlob": false,
                          "templateId": "#AdminWorkflows:Canton.Internal.Ping:Ping"
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        }
      }
    }
    
    query acs

    POST /v2/state/active-contracts

    {
      "verbose": false,
      "activeAtOffset": "{{ledgerEndOffset}}",
      "filter": {
        "filtersByParty": {
          "{{appUserParty}}": {
            "cumulative": [
              {
                "identifierFilter": {
                  "TemplateFilter": {
                    "value": {
                      "includeCreatedEventBlob": false,
                      "templateId": "#AdminWorkflows:Canton.Internal.Ping:Ping"
                    }
                  }
                }
              }
            ]
          }
        }
      }
    }
    

    These were created with the splice-node bundle 0.4.20.

  4. David_Martins 1

    Hello @WallaceKelly, thank you for your reply,

    The change from “unit“ to “record“ did work as intended, however, I believe the error in question was a bit opaque, as it did not refer to what it was expecting instead of the “ValueUnit“.

    In any case thanks for the resolution, I’ll close the topic.