Creating contract from script data

Hi… suppose if we have a some contract and we have written script for that contract also with some mock data .is it is possible that script will work like bootstrap script that whenever Daml will start it will create contract on the ledger with that script data and we can check those contracts on Navigator. Please try to explain with some example.

Hello @Joy_K

Yes, this is possible. To run a daml script on startup, you may include it in your daml.yaml file. Within your daml.yaml file, you can add an option, “init-script”, that will run your specified daml script on startup.

For example, if I had a script named ‘createToken’, residing in the path /Scripts/Token.daml, I would add the following into the daml.yaml file:
init-script: Scripts.Token:createToken

Hope this helps!

Thank you so much …it worked! :grinning:

You can also use the daml script command to run a script on an existing ledger.