From Concept to Production in under 10 minutes - Introducing the Project : DABL alpha
Nothing is loaded from YouTube until you press play, and then without tracking cookies.
About this video
๐ Get started with Daml: bit.ly/tryDaml ๐ Learn more about Daml Smart Contracts: bit.ly/learn_daml ๐ฎCheck out our blogs: bit.ly/daml-blog-engineering ๐ Become a Daml certified expert: bit.ly/daml-certification
Transcript
1,122 wordsCaptions as YouTube publishes them, usually machine-generated, so names such as Daml and Canton can be misheard.
- 0:00
everyone today I'm gonna use project dabble and demo to write a chat app in under ten minutes let's see how that works let me log into the project that'll use my Google credentials and I'm presented with the main page let's go ahead and create the project for my chat packet I'm gonna name it chat and the ledger that is gonna store all the chat messages let's name it chat ledger hit submit and I see that my ledger is
- 0:36
being created and deployed on the cloud now time to write my down model switch to the terminal and use the demo SDK to create a new scalar project name it hello chat okay now change directory inside hello chat and launch vehicle great I see a skeleton app with a demo folder and a Tamil Yama file let me go ahead and delete this because I'm not gonna need it and create a new demo file
- 1:23
from scratch I'm gonna name this file sample and this is going to make my module named sample as well now this is going to have very simple it's going to have two different demo templates let's create the first one we'll call it greeter this is what the party is going to use to actually send messages to messages through other parties let's add a demo contract key here skews the party
- 2:03
and the maintainer is going to be the now we'll give our party control a choice to say hello and we're going to be creating contract IDs of type hello message we obviously need to send this message to someone so one of our arguments here is going to be to have this be a party and then we're going to say something so let's add another field called message type text and we do want
- 2:41
to create hello message with the sender being the party the recipient being the - and the message that is implied now let's make this choice non consuming so that the party can send any messages they want and let's go ahead and define the hello message template this is going to have sender recipient it's also going to be departing and the message it's also going to be of type text now obviously this is going to be signed by
- 3:36
the sender party and disclose to the recipient through the observer keyword great that's all we need let's go ahead and compile this to add our table I'm gonna help put this on my desktop name it hello dar and we're done switch back to project devil my new ledger is ready so I'm just gonna go ahead and upload the door that there just created here it is drag and drop it into my chat letter wait a few moments I see the notifications that it has been
- 4:28
deployed and actually enter my new ledger in order to verify and check my new model so as you can see here this is the demo file I just wrote and my letter is ready to be used now I go to the live data tab I see a ledger admin which has two contracts and let's go start defining the users of a chat or chat application now go to add party and I'm going to define Alice and Bob I just
- 4:55
added two parties on the ledger these parties now exist in the ledger settings as well and they're fully authenticated with JSON web tokens great now let's go ahead and connect a UI to this back-end I happen to have UI code here and all I need to do is copy paste the JSON web tokens for each of the parties as well as the API path for the ledger I just created let me go ahead and do that so
- 5:26
for Alice when select Alice here copy the token go back to vs code paste that token and do exactly the same football great let me save that last thing is going to the package station file and adding a proxy which is going to be the AAP api path for project down thankfully you have this also in my ledger setting so I just copy it paste it here save this and I'm all set around my UI so what I'm gonna do is I'm gonna go to my other tab and do a yarn start this is
- 6:09
going to bring up a web server and development mode and it's going to launch a new tab with Yui waiting a few moments for this to launch and we'll be in business okay looks like we're in we're gonna use Alice to log in here and we see that Alice already sees the contract that's been created for her and has the hello messages tab in a greeter tab same thing with Bob so in order to be able to send messages as we said we need a greeter contract let's go ahead and create that in project data go to
- 7:02
project tab o go to Alice add a contract we're adding this as Alice so and we're selecting the greeter template we hit next and since Alice is creating that for herself we choose Alice here and we do have a greeter contract for Alice let's do quickly the same for Bob and Bob here as well okay now bob has their own reader contract as well go back to our UI hit a simple refresh and we see now that alice is able to greet other people now last thing we want is to send a message to Bob we see
- 7:43
here that we're using party IDs instead of parties so what we have to do is go and get Bob's party ID in order for Alice to extend them to send them a message I'm going to go again to ledger settings select Bob from the party ID list click copy and paste it on the field of sending a message and right hey Bob click say hello and if I go to hello messages I actually see that I sent a
- 8:12
message to Bob now if I log out and log back in as well Bob sees his own contracts his own greener contract and inhale our messages he sees Alice that has sent him a message we can actually reply to Alice right now so copy paste the sender go to greeter paste here and say yeah Alice click on say hello and guess what another hello message has been created so this is a fully functional back-end authenticated and running in project up and all of that under 10 minutes thanks for watching guys