To get around this error, I believe you can safely delete the last two lines from your daml.yaml
file.
sandbox-options:
- --wall-clock-time
I’m thinking it is this bug.
Hi Wallace, thank you for coming back to me again!
I deleted both lines. Now it opens, but when I play a role (let’s say Jerry), and I want to register the first contract, it seems to work, but the contract is not created. A small “access denied” black symbol is at the top right, close to the date.
Other suggestions?
I don’t remember where the Jerry, Elaine, and Kramer tutorial is. Can point us to the directions you are following?
Could you copy-and-paste your code into this thread so that I can try it out myself. Maybe I’ll be able to see what is going on, instead of having to guess.
Regarding other resources, I suspect you are looking in the right place… Become a Daml Developer.
Great! Sure, thanks a lot.
This is the Main.daml
`module Main where
–import Daml.Script
type ItemCustodyId = ContractId ItemCustody
–track chain of property
template ItemCustody
with
owner : Party
custodian : Party
neighbour: Party
itemName: Text
meterCount: Int --shutter clicks
where
signatory owner
observer custodian
observer neighbour
– depreacated sinax controller … can
–controller owner can
–ReleaseItemTo : ContractID ItemCustody
–with
–friend : Party
–do
choice ReleaseItemTo
: ItemCustodyId
with
friend : Party
currentMeterCount : Int
controller owner
do
create this with
custodian = friend
meterCount = currentMeterCount
choice ReturnItemTo
: ItemCustodyId
with
rightfulOwner : Party
currentMeterCount :Int
controller custodian
do
create this with
owner = rightfulOwner
meterCount = currentMeterCount
–test
{-
setup : Script ItemCustodyId
setup = script do
jerry ← allocateParty “Jerry”
elaine ← allocateParty “Elaine”
kramer ← allocateParty “Kramer”
brandNewCamera <- submit jerry do
createCmd ItemCustody with
owner = jerry
custodian = jerry
neighbour = kramer
itemName = "Really Expensive Camera"
meterCount = 347
elaineHasCamera <- submit jerry do
exerciseCmd brandNewCamera ReleaseItemTo with friend = elaine, currentMeterCount = 360
submit elaine do
exerciseCmd elaineHasCamera ReturnItemTo with rightfulOwner = jerry, currentMeterCount = 10004
-}
'
and this is the daml.yaml
’ sdk-version: 2.4.0
name: MyBorrowApp
source: daml
version: 1.0.0
#init-script: Main:setup
parties:
- Jerry
- Elaine
- Kramer
dependencies:
- daml-prim
- daml-stdlib
- daml-script
exposed-modules:
- Main
#sandbox-options:
- --wall-clock-time
#navigator-options:
- --feature-user-management=false
’
Sorry I don’t know why the daml.yaml get copied in this strange way
To paste long sections of code into this site, use three tick marks on the line before and the line after your code.
This is without the three tick marks.
This is with the three tick marks.
name: MyBorrowApp
source: daml
version: 1.0.0
#init-script: Main:setup
parties:
- Jerry
- Elaine
- Kramer
dependencies:
- daml-prim
- daml-stdlib
- daml-script
exposed-modules:
- Main
#sandbox-options:
# - --wall-clock-time
#navigator-options:
# - --feature-user-management=false```
1 Like
--import Daml.Script
type ItemCustodyId = ContractId ItemCustody
--track chain of property
template ItemCustody
with
owner : Party
custodian : Party
neighbour: Party
itemName: Text
meterCount: Int --shutter clicks
where
signatory owner
observer custodian
observer neighbour
-- depreacated sinax controller ... can
--controller owner can
--ReleaseItemTo : ContractID ItemCustody
--with
--friend : Party
--do
choice ReleaseItemTo
: ItemCustodyId
with
friend : Party
currentMeterCount : Int
controller owner
do
create this with
custodian = friend
meterCount = currentMeterCount
choice ReturnItemTo
: ItemCustodyId
with
rightfulOwner : Party
currentMeterCount :Int
controller custodian
do
create this with
owner = rightfulOwner
meterCount = currentMeterCount
--test
{-
setup : Script ItemCustodyId
setup = script do
jerry <- allocateParty "Jerry"
elaine <- allocateParty "Elaine"
kramer <- allocateParty "Kramer"
brandNewCamera <- submit jerry do
createCmd ItemCustody with
owner = jerry
custodian = jerry
neighbour = kramer
itemName = "Really Expensive Camera"
meterCount = 347
elaineHasCamera <- submit jerry do
exerciseCmd brandNewCamera ReleaseItemTo with friend = elaine, currentMeterCount = 360
submit elaine do
exerciseCmd elaineHasCamera ReturnItemTo with rightfulOwner = jerry, currentMeterCount = 10004
-}```
Thanks! Sorry I put only one ` previously
Some of the things related to users/parties and how the Navigator loads those have changed since that video was recorded.
Here is working code:
daml.yaml
sdk-version: 2.4.0
name: MyBorrowApp
source: daml
version: 1.0.0
init-script: Main:setup
dependencies:
- daml-prim
- daml-stdlib
- daml-script
exposed-modules:
- Main
navigator-options:
- --feature-user-management=false
Main.daml
module Main where
import Daml.Script
type ItemCustodyId = ContractId ItemCustody
--track chain of property
template ItemCustody
with
owner : Party
custodian : Party
neighbour: Party
itemName: Text
meterCount: Int --shutter clicks
where
signatory owner
observer custodian
observer neighbour
choice ReleaseItemTo
: ItemCustodyId
with
friend : Party
currentMeterCount : Int
controller owner
do
create this with
custodian = friend
meterCount = currentMeterCount
choice ReturnItemTo
: ItemCustodyId
with
rightfulOwner : Party
currentMeterCount :Int
controller custodian
do
create this with
owner = rightfulOwner
meterCount = currentMeterCount
setup : Script ItemCustodyId
setup = script do
jerry <- allocateParty "Jerry"
elaine <- allocateParty "Elaine"
kramer <- allocateParty "Kramer"
brandNewCamera <- submit jerry do
createCmd ItemCustody with
owner = jerry
custodian = jerry
neighbour = kramer
itemName = "Really Expensive Camera"
meterCount = 347
elaineHasCamera <- submit jerry do
exerciseCmd brandNewCamera ReleaseItemTo with friend = elaine, currentMeterCount = 360
submit elaine do
exerciseCmd elaineHasCamera ReturnItemTo with rightfulOwner = jerry, currentMeterCount = 10004
The things to notice are:
-
Instead of listing the Parties in the daml.yaml file, use --feature-user-management=false
as described at Navigator — Daml SDK 2.4.0 documentation.
-
Define a setup
script to allocate the parties. Navigator will then use those parties to populate the Navigator login screen.
Hope that helps!
Hi Wallace, how can it be then when I open I see already the contracts created and archived? From the tutorial, I understand that I should see the template but not the contracts, as I haven’t done anything yet.
I should open the template, insert the date and create the contract. Instead it’s all already there so how can I play with the 3 roles?
That is because the setup
script includes three commands (one createCmd
and two exerciseCmd
s). If you would like to start without those, you can comment them out of the setup
script and restart everything. Even if you comment out the commands, you will want to leave in the allocateParty
lines.
I’m guessing your layout looks something like this, where all the parties include a long unhelpful identifier.
Yes, that reflects that the representation of “parties” in Daml has evolved to include a unique identifier. And Navigator is still just naively displaying the full name (with the newly added unique identifier.) The display is accurate, but not as clean as we might like when learning. It’s not straightforward to know who party party-9b6faed2-6bb6-4cd2-bfc0-58ca6f2b024f::1220a220a71c...
is.
Here is a way to get around this issue. In your setup script, add a “hint” to the party allocation.
setup = script do
-- jerry <- allocateParty "Jerry"
-- elaine <- allocateParty "Elaine"
-- kramer <- allocateParty "Kramer"
jerry <- allocatePartyWithHint "Jerry" (PartyIdHint "Jerry")
elaine <- allocatePartyWithHint "Elaine" (PartyIdHint "Elaine")
kramer <- allocatePartyWithHint "Kramer" (PartyIdHint "Kramer")
After adding the party id hint, we can at least associate the identifier with the party as we know them.
Remember, after making changes to your setup
script, stop the running services and rerun daml start
.