# Code not running

**URL:** <https://forum.canton.network/t/code-not-running/3243>\
**Category:** App Development\
**Created:** [October 1, 2021, 10:50am UTC](https://forum.canton.network/t/code-not-running/3243 "2021-10-01T10:50:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![growtogether](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/growtogether/32/3306_2.png) [@growtogether](https://forum.canton.network/u/growtogether)\
**Post date:** [October 1, 2021, 10:50am UTC](https://forum.canton.network/t/code-not-running/3243/1 "2021-10-01T10:50:28Z")

</div>

I cant compile it due to errors

```haskell
daml 1.2
module Main where

template Proposal 
 with
  validationId : Int
  proposalDetails : ProposalDetails
  borrower : Party
  lender : Party
 where
  signatory lender
  observer borrower
  key (lender,validationId) : (Party,Int)
  maintainer key._1
  controller borrower can
   AcceptOffer : ContractId FinalAgreement
    do
     exerciseByKey @VerifiedRequest (borrower,validationId) ArchiveVerified
     create FinalAgreement with
     validationId = validationId
     proposalDetails = proposalDetails
     borrower = borrower
     lender = lender
controller borrower can
  RejectOffer : ()
do
 assertMsg "Offer Rejected by Borrower" (1==1)

template LoanRequest
 with
   borrower : Party
   content : UserInformation
 where
   signatory borrower

template Lend
 with
  lender : Party
  value : Decimal
  depositdate: Date
  currency: String

 where
  signatory lender
  observer:lender

template borrow
 with
  borrower : Party
  value:
  borrowdate:
  interest:
 where
  signatory borrower
  observer borrower

template pool
 with
  amount:
 where
  signatory borrower

template Validator
 with
  validator : Party
  lender : Party
  content : UserInformation
  amount : Decimal
 where
  signatory validator
  observer lender

```

---

<div class="post-metadata">

**Author:** ![quidagis](https://avatars.discourse-cdn.com/v4/letter/q/dbc845/32.png) [@quidagis](https://forum.canton.network/u/quidagis)\
**Post date:** [October 1, 2021, 10:13pm UTC](https://forum.canton.network/t/code-not-running/3243/2 "2021-10-01T22:13:30Z")

</div>

Hi @growtogether thank you for the post.

I edited my post after doing some quick research in the Daml Documentation for [Data Types](https://docs.daml.com/daml/reference/data-types.html).

Also converted all the Template names to start with Uppercase, and indented the one odd Controller code block, and created a `Data Type` for `UserInformation`.

Adjusted code:

```haskell
module Main where

template Proposal 
 with
  validationId : Int
  proposalDetails : Text
  borrower : Party
  lender : Party
 where
  signatory lender
  observer borrower
  key (lender,validationId) : (Party,Int)
  maintainer key._1
  
  controller borrower can
   AcceptOffer : ContractId FinalAgreement
    do
     exerciseByKey @VerifiedRequest (borrower,validationId) ArchiveVerified
     
     create FinalAgreement with
       validationId = validationId
       proposalDetails = proposalDetails
       borrower = borrower
       lender = lender

  controller borrower can
    RejectOffer : ()
      do
        assertMsg "Offer Rejected by Borrower" (1==1)

-- Unsure where this Data Type should sit.
data UserInformation = UserInformation
  with
    name : Text
    dateOfBirth : Date
    age : Int
    location : Text
    city : Text

template LoanRequest
 with
   borrower : Party
   content : UserInformation
 where
   signatory borrower

template Lend
 with
  lender : Party
  value : Decimal
  depositdate: Date
  currency: String

 where
  signatory lender
  observer lender

template Borrow
 with
  borrower : Party
  value: Text
  borrowdate: Date
  interest: Int
 where
  signatory borrower
  observer borrower

template Pool
  with
    amount: Int
  where
    signatory borrower

template Validator
 with
  validator : Party
  lender : Party
  content : UserInformation
  amount : Decimal
 where
  signatory validator
  observer lender

```

It looks like you need some Type definitions for:

- FinalAgreement
- @VerifiedRequest

I don’t know if a `Data Type` is supposed to go in the header of the `Main.daml` or above the first instance, perhaps some of the experts can confirm/deny it’s location.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![growtogether](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/growtogether/32/3306_2.png) [@growtogether](https://forum.canton.network/u/growtogether)\
**Post date:** [October 4, 2021, 3:34pm UTC](https://forum.canton.network/t/code-not-running/3243/3 "2021-10-04T15:34:12Z")

</div>

Thank you so much!

---

<div class="post-metadata">

**Author:** ![Stephen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stephen/32/102_2.png) [@Stephen](https://forum.canton.network/u/Stephen)\
**Post date:** [October 4, 2021, 3:35pm UTC](https://forum.canton.network/t/code-not-running/3243/4 "2021-10-04T15:35:39Z")

</div>

> [@quidagis](#):
>
> I don’t know if a `Data Type` is supposed to go in the header of the `Main.daml` or above the first instance, perhaps some of the experts can confirm/deny it’s location.

The only ordering that matters in Daml is `LANGUAGE` and other pragmas, then `module` header, then all `import`s (order doesn’t matter), then everything else (order doesn’t matter). So feel free to choose whatever order is most aesthetically pleasing.

---

<div class="post-metadata">

**Author:** ![growtogether](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/growtogether/32/3306_2.png) [@growtogether](https://forum.canton.network/u/growtogether)\
**Post date:** [October 5, 2021, 9:18am UTC](https://forum.canton.network/t/code-not-running/3243/5 "2021-10-05T09:18:12Z")

</div>

SHould I create a new template for finalAgreement? because it gives me errors

---

<div class="post-metadata">

**Author:** ![Gary\_Verhaegen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gary_verhaegen/32/81_2.png) [@Gary\_Verhaegen](https://forum.canton.network/u/Gary_Verhaegen)\
**Post date:** [October 5, 2021, 2:03pm UTC](https://forum.canton.network/t/code-not-running/3243/6 "2021-10-05T14:03:12Z")

</div>

You have code trying to `create` contracts of type `FinalAgreement`, as well as manipulating `ContractId FinalAgreement`, so, yes, you need a template definition for it.
