# Project quickstart - A question?

I am analyzing this project `daml new quickstart --template quickstart-java`

Here are some doubts, if the Bank grants a balance of 100 euros for Alice, how can it be that Alice can continue issuing 2 promissory notes of 60 euros each that exceed her limit of 100.

This project is just a test of how the templates work and in real life, you should see some control mechanism to not overdraw more than what Alice has which is 100 euros.

In the image, you can see that I have transferred to Bod two promissory notes of 60 euros each, which together give 120 euros, more than what Alice has.

Who should do the balance limit control, the application, or the smart contract that I want to develop?

2 Likes

Hi magzupao

This example is about IOUs and parties are equal in the choices that they can exercise on them. Any party can create a new IOU of any amount and transfer it to any other party. If Bob does not trust Alice but he trusts the EUR_Bank, Alice can split her IOU from the EUR_Bank to 60+40 and transfer the resulting 60 EUR IOU to Bob.

You can control the balance limit by modelling the Bank, Account and Deposit in Daml, you donâ€™t need to create any other application code for it.

2 Likes

The two crucial points here are the issuer and more generally signatories. If you look at the code for the Iou template, you can see that it has both the issuer and the owner as signatories. Alice can create an arbitrary number of self-issued Ious where she is both the issuer and the owner and that appears to be what has happened in your example. However, other parties can see that those Ious have been issued by Alice rather than `USD_Bank` which probably means that they wonâ€™t place any value in those Ious.

What Alice cannot do is to turn the 110\$ Iou issued by `USD_Bank` into two `Ious` also issued by `USD_Bank` with a combined value that is higher than 110\$. Thatâ€™s prevented by the model. The only choice on `Iou` that Alice can issue are `Iou_Split` which preserves value`, `Iou_Merge`which preserves value of the two merged Ious and`Iou_Transfer` which also preserves the value.

1 Like

Hello, could you give an example of how this condition can be fulfilled:

Bank issues 100 â†’ Alice has 100 â†’ Alice transfers to Bob 60.

Where I see that Alice has 40 balance.

Thanks

1 Like

You can see this (Alice transferring 40 to Bob and having 60 left) in the `Tests/Iou.daml` file of the project if you run the Scripts there (by clicking on â€śScript resultsâ€ť)

The relevant code is:

``````  -- Alice splits the IOU and transfers part of it to Bob.
split <- submit alice do
exerciseCmd iouAliceCid Iou_Split with splitAmount = 40.0
iouTransferCid <- submit alice do
exerciseCmd (fst split) Iou_Transfer with newOwner = bob
``````

You can then check off â€śShow archivedâ€ť on the Script tab and youâ€™ll be able to see this happened:

If you look through youâ€™ll see that old contracts get archived (represented by a strikethrough) and can no longer be used. So when Alice splits her money and sends it to Bob she can no longer access her original 100 USD (id #2:1) as it gets archived during the split. The 40 USD she sends to Bob also gets archived (id #4:1) and when Bob combines his 40 USD (id #6:1) with his existing 30 USD from Acme to that gets archived as well and he has a new IOU for USD from Acme in the amount of 70 USD (id #7:3)

This code does some other things as well but as you can see when â€śShow archivedâ€ť is unchecked the ledger still sums correctly with the total balance of the 130 USD issued between Alice and Bob still equaling 130 (note contract id #11:1 here is referring to another test where EUR was issued).

2 Likes

Elaborating a little bit more on the meaning behind this code, we need to consider what money is. Letâ€™s take a step back, through history.

At some point, people decided that gold was valuable. (Donâ€™t ask me why.) But transporting it was inconvenient (itâ€™s heavy), so people decided to trust â€śbanksâ€ť to hold their gold for them, and when they needed to pay, instead of giving other people nuggets of gold, they would give them signed papers that said â€śyou can go and take gold from my account at this bankâ€ť.

As time went by, standardization occurred. Countries decided to create central banks, and commercial banks decided to trust central banks to hold their gold. Over time, people got comfortable with the idea that a note that allows you to take gold from a bank account is pretty much as good as the gold itself, and actually exchanging notes for gold became more and more rare. People just traded the paper notes directly.

Then the central banks decided to get rid of their gold, and nobody noticed. People just kept trading stuff and services for paper notes.

Anyone can take a piece of paper and write â€ś100 USDâ€ť on it. But weâ€™ve all agreed that we only trust the US Federal Reserve to print â€śvalidâ€ť USD notes. Similarly, weâ€™ve all agreed to trust the European Central Bank to print â€śvalidâ€ť Euro notes.

Letâ€™s ignore the possibility of fraud and assume that signatures can easily be checked for validity. If I come to you and give you a note that says â€ś100â€ť, you will give it a different value based on who signed it: if it was signed by the US Federal Reserve, youâ€™ll take it as being worth 100 USD. If it was signed by the European Central Bank, youâ€™ll take it as being worth 100 EUR. If it was signed by me personally, youâ€™ll have to decide for yourself how much trust you put into that. Maybe I have a really good reputation. Maybe youâ€™ve never heard of me.

This concept of â€śwho signed itâ€ť, fully separate from â€śwho currently owns itâ€ť, is what the â€śissuerâ€ť in that template represents.

In princple, there is nothing special about the US Federal Reserve, and in a Daml system, they would just be another `Party`. Itâ€™s up to Bob to decide which issuers he trusts.

So whatâ€™s the value-add from Daml? In this case, the value is that if Bob trusts Acme Bank (the issuer), Bob does not need to trust Alice (the current owner) in any way to be confident that the money he is receiving is valid, has not been double spent, etc.

This is pretty much the same situation as in the real world (except forgery is much harder): you can trust a \$100 note not because you trust the person who gives it to you, but because you trust the US Federal Reserve (and the fact that they engineered those notes to be hard to forge).

With this additional context, hopefully it should no longer be surprising that Alice can create as much money as she wants. Itâ€™s just that the `issuer` for that money will be Alice, and presumably not many people will decide to trust her on that.

1 Like