- I create the project
daml new bikeshopdemo1 --template empty-skeleton
cd bikeshopdemo1
daml studio
- I create the file BikeShop.daml file in the path ./daml/
BikeShop.daml – file contents:
module BikeShop where
import Daml.Script
import DA.Date
data Currency = USD | EUR | GBP | CHF
deriving (Eq, Show)
template Cash
with
issuer: Party
owner: Party
currency: Currency
amount: Decimal
where
signatory issuer
controller owner can
Transfer : ContractId Cash
with
newOwner: Party
do
create this with owner=newOwner
template BikeRepair
with
bikeShop: Party
bikeOwner: Party
description: Text
price: Decimal
paymentDue: Date
where
signatory bikeShop, bikeOwner
controller bikeOwner can
Pay : ContractId Cash
with
cashCid: ContractId Cash
do
exercise cashCid Transfer with newOwner=bikeShop
template BikeRepairProposal
with
proposer: Party
receiver: Party
proposal: BikeRepair
where
signatory proposer
controller receiver can
Accept : ContractId BikeRepair
do
create proposal
test = do
bank <- allocateParty "SwissBank"
martin <- allocateParty "Martin"
bikeshop <- allocateParty "BikeShop"
let
cash = Cash
with
issuer = bank
owner = martin
currency = CHF
amount = 200.0
cashCid <- submit bank do
createCmd cash
let
bikeRepair = BikeRepair
with
bikeShop = bikeshop
bikeOwner = martin
description = "fix the bike"
price = 200.0
paymentDue = date 2021 Feb 17
proposalCid <- submit bikeshop do
createCmd BikeRepairProposal
with
proposer = bikeshop
receiver = martin
proposal = bikeRepair
repairCid <- submit martin do
exerciseCmd proposalCid Accept
submit martin do
exerciseCmd repairCid Pay with cashCid
pure()
- I compile the project
daml build
- I create the ui/ interface
daml codegen js .daml/dist/bikeshopdemo1-0.0.1.dar -o ui/daml.js
- Deploy
daml start
vagrant@vagrant:~/daml/bikeshopdemo1$ cd .daml/
dist/ interfaces/ package-database/
vagrant@vagrant:~/daml/bikeshopdemo1$ daml start
SDK 1.11.1 has been released!
See https://github.com/digital-asset/daml/releases/tag/v1.11.1 for details.
SDK 1.11.1 has been released!
See https://github.com/digital-asset/daml/releases/tag/v1.11.1 for details.
Compiling bikeshopdemo1 to a DAR.
Created .daml/dist/bikeshopdemo1-0.0.1.dar
Waiting for sandbox to start:
INFO: Slf4jLogger started
INFO: Listening on localhost:6865 over plain text.
____ ____
/ __/__ ____ ___/ / / ___ __ __
_\ \/ _ `/ _ \/ _ / _ \/ _ \\ \ /
/___/\_,_/_//_/\_,_/_.__/\___/_\_\
INFO: Initialized sandbox version 1.8.0 with ledger-id = 87e12448-1bc6-4dc9-9035-a1afb831fe26, port = 6865, dar file = List(.daml/dist/bikeshopdemo1-0.0.1.dar), time mode = wall-clock time, ledger = in-memory, auth-service = AuthServiceWildcard$, contract ids seeding = strong
Waiting for navigator to start:
_ __ _ __
/ |/ /__ __ __(_)__ ____ _/ /____ ____
/ / _ `/ |/ / / _ `/ _ `/ __/ _ \/ __/
/_/|_/\_,_/|___/_/\_, /\_,_/\__/\___/_/
/___/
Version 1.8.0
Frontend running at http://localhost:7500.
...........Waiting for JSON API to start:
13:51:25.110 [main] INFO com.daml.http.Main$ - Config(ledgerHost=localhost, ledgerPort=6865, address=127.0.0.1, httpPort=7575, portFile=None, packageReloadInterval=5 seconds, packageMaxInboundMessageSize=None, maxInboundMessageSize=4194304, tlsConfig=TlsConfiguration(false,None,None,None,REQUIRE,false), jdbcConfig=None, staticContentConfig=None, allowNonHttps=true, accessTokenFile=None, wsConfig=None)
13:51:25.786 [http-json-ledger-api-akka.actor.default-dispatcher-5] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
13:51:29.027 [http-json-ledger-api-akka.actor.default-dispatcher-6] INFO com.daml.http.HttpService$ - Connected to Ledger: 87e12448-1bc6-4dc9-9035-a1afb831fe26
13:51:29.029 [http-json-ledger-api-akka.actor.default-dispatcher-6] INFO com.daml.http.HttpService$ - contractDao: None
13:51:31.971 [http-json-ledger-api-akka.actor.default-dispatcher-6] INFO com.daml.http.PackageService - new package IDs loaded: 305f88952990a57bdefb3a8556ba65d7951606397564270186108157f73e95e1, c1f1f00558799eec139fb4f4c76f95fb52fa1837a5dd29600baa1c8ed1bdccfd, 733e38d36a2759688a4b2c4cec69d48e7b55ecc8dedc8067b815926c917a182a, 02da7f6b391f26e5a4c6e1e120b84d3a570fb0e0781e50a60b1085cce7c265cc, bfcd37bd6b84768e86e432f5f6c33e25d9e7724a9d42e33875ff74f6348e733f, 518032f41fd0175461b35ae0c9691e08b4aea55e62915f8360af2cc7a1f2ba6c, cc348d369011362a5190fe96dd1f0dfbc697fdfd10e382b9e9666f0da05961b7, 6839a6d3d430c569b2425e9391717b44ca324b88ba621d597778811b2d05031d, 7cbb10d2488454034d290b8c16b7cfa4fc59c749ca379696c54f74bf453f52b3, 99a2705ed38c1c26cbb8fe7acf36bbf626668e167a33335de932599219e0a235, a8ea38e5992fb992237db9973af9ce63fa78ba8fb103cea3a5d739ac313c909c, 76bf0fd12bd945762a01f8fc5bbcdfa4d0ff20f8762af490f8f41d6237c6524f, e22bce619ae24ca3b8e6519281cb5a33b64b3190cc763248b4c3f9ad5087a92c, d58cf9939847921b2aab78eaa7b427dc4c649d25e6bee3c749ace4c3f52f5c97, 6c2c0667393c5f92f1885163068cd31800d2264eb088eb6fc740e11241b2bf06, d14e08374fc7197d6a0de468c968ae8ba3aadbf9315476fd39071831f5923662, 057eed1fd48c238491b8ea06b9b5bf85a5d4c9275dd3f6183e0e6b01730cc2ba, e491352788e56ca4603acc411ffe1a49fefd76ed8b163af86cf5ee5f4c38645b, 40f452260bef3f29dede136108fc08a88d5a5250310281067087da6f0baddff7, 8a7806365bbd98d88b4c13832ebfa305f6abaeaf32cfa2b7dd25c4fa489b79fb
13:51:32.996 [http-json-ledger-api-akka.actor.default-dispatcher-5] INFO com.daml.http.Main$ - Started server: ServerBinding(/127.0.0.1:7575)
......................
Press 'r' to re-build and upload the package to the sandbox.
Press 'Ctrl-C' to quit.
-
load in the project by invoking it from the browser http://localhost:7500
-
The application loads in the web browser, I log in, I choose a template, I enter the data but the contract is not created.
-
when I check the ui/ folder there is only one daml.js file
so my questions are;
- do I need to create other files and if so how do I do it, is there an example (a guide)?
- or what is the error because the contract is not created.
RESUMEN
in other examples I have seen that the ui/ folder has more files and also when the contract is created an icon appears for a few seconds at the top right of the browser indicating that the contract is created, a check is displayed and then disappears.
In this example the check does not appear but an icon appears that is like a zero with a diagonal inside and the contract is not created.