# Quest №5

By [TTTTTTTTTTTTTTTTTTTTTT](https://paragraph.com/@tttttttttttttttttttttt) · 2025-10-13

---

1\. Створюємо новий проект

daml new persondata --template skeleton

cd persondata/daml  
  
Далі в Explorer знаходимо папку persondata, відкрваємо папку daml та бачимо файл Main.daml  
Його потрібно перейменувати у PersonData.daml

![](https://storage.googleapis.com/papyrus_images/c7585d30139efd2d2c1563c99f2d3ffb9b1d5c1749316e58dedf0b781da7426d.png)

  
Відкриваємо PersonData.daml видаляємо вміст та вставляємо новий

    module PersonData where
    
    import Daml.Script
    import DA.Optional (Optional(..))
    import DA.List (delete)
    
    data PersonKey = PersonKey with
       keyIssuer : Party
       keyDataId : Text
     deriving (Eq, Show)
    
    template PersonData
     with
       issuer : Party  
       owner : Party    
       dataId : Text     
       personalInfo : (Text, Text, Int)
       addresses : [Text]
       contact : Optional Text
     where
       signatory issuer, owner
       ensure dataId /= ""
    
       choice UpdatePersonalInfo : ContractId PersonData
         with
           newInfo : (Text, Text, Int)
         controller owner
         do
           archive self
           create this with personalInfo = newInfo
    
       choice AddAddress : ContractId PersonData
         with
           newAddress : Text
         controller owner
         do
           archive self
           create this with addresses = newAddress :: addresses
    
       choice SetContact : ContractId PersonData
         with
           newContact : Text
         controller owner
         do
           create this with contact = Some newContact
    
       choice ClearContact : ContractId PersonData
         controller owner
         do
           archive self
           create this with contact = None
    
    template PersonDataProposal
     with
       proposal : PersonData
     where
       signatory proposal.issuer
       observer proposal.owner 
      
       choice Accept : ContractId PersonData
         controller proposal.owner
         do
           create proposal
    test_person_data = script do
       issuer <- allocateParty "IssuerParty"
       owner <- allocateParty "OwnerParty"
      
       let initialPersonData = PersonData with
               issuer = issuer
               owner = owner
               dataId = "KYC-001"
               personalInfo = ("Jane", "Doe", 35)
               addresses = ["10 Downing Street"]
               contact = Some "old.contact@example.com"
              
       proposalCid <- submit issuer do
           createCmd PersonDataProposal with
               proposal = initialPersonData
    
       personCid <- submit owner do
           exerciseCmd proposalCid Accept
    
       Some contract <- queryContractId issuer personCid
       assert (contract.contact == Some "old.contact@example.com")
       
       let personKey = PersonKey with 
             keyIssuer = issuer
             keyDataId = "KYC-001"
       
       newCid <- submit owner do
         exerciseCmd personCid SetContact with
             newContact = "new.contact@example.com"
        
       Some newContract <- queryContractId owner newCid
       assert (newContract.contact == Some "new.contact@example.com")
       return ()
    

  
Натискаємо Ctrl+S для зберігання.  
  
  
Над test\_person\_data натискаємо на scrip results та у вікні результатів ставимо галочку на Show archived

![](https://storage.googleapis.com/papyrus_images/2a712055f52b5e5c3798d4bb613094bef02bed25b11af6d3b3f5ef356133647c.png)

На скріні має бути повністю видно верхню табличку і все

![](https://storage.googleapis.com/papyrus_images/80c2fd3c1d98682ca55a1a83cdb5cf02d4dabfe80bf03a4ef7b99fb4b0ae0c5c.png)

---

*Originally published on [TTTTTTTTTTTTTTTTTTTTTT](https://paragraph.com/@tttttttttttttttttttttt/quest-5)*
