Skip to content
CCPEDIAby Unity Nodes
App Development

While running scenarios file with daml script command against in memory snadbox, it is throwing Invalid Party arguments as parties are already allocated with first script

4 posts434 views7 likesLast activity Nov 2020

  1. Abhishek_JainOP 3

    I was trying to run 2 script with daml script command then execution of second script is failing with error Parties arguments are invalid as it is already assigned.

    Attaching the 2 script file that I am running one after the another.

    daml script --dar .\.daml\dist\quickstart-0.0.1.dar --script-name Main:initialize --ledger-host localhost --ledger-port 6865
    
    daml script --dar .\.daml\dist\quickstart-0.0.1.dar --script-name Main1:initialize --ledger-host localhost --ledger-port 6865
    

    As I am new to Daml so I am not allowed to attach the script files so pasting content of the script file here -
    Main.daml

    -- Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
    -- SPDX-License-Identifier: Apache-2.0
    
    
    module Main where
    
    import Daml.Script
    import Iou
    import IouTrade()
    
    initialize : Script ()
    initialize = do
      -- allocate parties
      alice <- allocatePartyWithHint "Alice" (PartyIdHint "Alice")
      bob <- allocatePartyWithHint "Bob" (PartyIdHint "Bob")
      usBank <- allocatePartyWithHint "USD_Bank" (PartyIdHint "USD_Bank")
      eurBank <- allocatePartyWithHint "EUR_Bank" (PartyIdHint "EUR_Bank")
    
      -- Banks issue IOU transfers.
      iouEurBankCid <- submit eurBank do
        createCmd Iou with
          issuer = eurBank
          owner = eurBank
          currency = "EUR"
          amount = 100.0
          observers = []
    
      iouTransferAliceCid <- submit eurBank do
        exerciseCmd iouEurBankCid Iou_Transfer with newOwner = alice
    	
    
      pure ()
    

    Main1.daml

    -- Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
    -- SPDX-License-Identifier: Apache-2.0
    
    module Main1 where
    
    import Daml.Script
    import Iou
    import IouTrade()
    
    initialize : Script ()
    initialize = do
    
      -- allocate parties
      alice <- allocatePartyWithHint "Alice" (PartyIdHint "Alice")
      bob <- allocatePartyWithHint "Bob" (PartyIdHint "Bob")
      usBank <- allocatePartyWithHint "USD_Bank" (PartyIdHint "USD_Bank")
      eurBank <- allocatePartyWithHint "EUR_Bank" (PartyIdHint "EUR_Bank")
    
      iouUsBankCid <- submit usBank do
        createCmd Iou with
          issuer = usBank
          owner = usBank
          currency = "USD"
          amount = 110.0
          observers = [alice, bob, eurBank]
    
      iouTransferBobCid <- submit usBank do
        exerciseCmd iouUsBankCid Iou_Transfer with newOwner = bob
    
      submit bob do exerciseCmd iouTransferBobCid IouTransfer_Accept
      
      pure()
    

    Note : I have tried removing allocate party logic from second script file that runs later but then compilation is complaining

  2. Abhishek_Jain 3

    I figured out the issue from another discussion where Parties to be passed with --input-file if any script has already allocated the parties… More detail information can be found on https://docs.daml.com/daml-script/index.html?_ga=2.90836954.1389845661.1605168012-1584537048.1598874835

  3. cocreature 1

    Welcome to the forum @Abhishek_Jain, glad to see that you were able to solve your issue.

  4. anthony
    Abhishek_Jain:

    As I am new to Daml so I am not allowed to attach the script files so pasting content of the script file here -

    Welcome to the forum Abhishek! Pasting code is fine and the preferred method of sharing on the forum.