Skip to content
CCPEDIAby Unity Nodes
Discussions/App Development/Creating contract from script dataForum ↗

Creating contract from script data

App Development4 posts216 viewsLast activity Jun 2023
JO
Joy_KOP
Jun 2023

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.

SO
solomonchauda
Jun 2023

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!

JO
Joy_K
Jun 2023

Thank you so much …it worked! :grinning:

IA
Ianw1
Jun 2023

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

← Back to Discussions