# Init-script in canton

**URL:** <https://forum.canton.network/t/init-script-in-canton/6006>\
**Category:** App Development\
**Created:** [January 20, 2023, 7:58am UTC](https://forum.canton.network/t/init-script-in-canton/6006 "2023-01-20T07:58:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nagendra](https://avatars.discourse-cdn.com/v4/letter/n/9fc29f/32.png) [@nagendra](https://forum.canton.network/u/nagendra)\
**Post date:** [January 20, 2023, 7:58am UTC](https://forum.canton.network/t/init-script-in-canton/6006/1 "2023-01-20T07:58:33Z")

</div>

Hello,

I am trying to translate the below init-script we have into init.canton and have hard time doing so. Appreciate any help i could get!

```haskell
daml 1.2
module Setup where

import Daml.Script

import Role.Operator

data Parties = Parties with
  operator : Party

setup : Script ()
setup = do
  operator <- allocatePartyWithHint "Operator" $ PartyIdHint with partyIdHint = "Operator"
  opRole <- submit operator $ createCmd OperatorRole with operator

  pure ()

```

I have gotten this far

```haskell
import better.files._

val operator = participant1.parties.enable("Operator")
val operatorAssignment = Set(operator -> participant1)

// upload dar file to participants
val darPath = Option(System.getProperty("dar-path")).getOrElse("/.daml/dist/participant-${DAR_VERSION}.dar")
darPath.exists || sys.error(s"cannot find the dar file ${darPath}")
participants.all.dars.upload(darPath)

```

Is there a way we can ask canton to pick it like we do in daml.yaml, for example: `init-script:Setup:setup`

---

<div class="post-metadata">

**Author:** ![stefanobaghino-da](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stefanobaghino-da/32/7057_2.png) [@stefanobaghino-da](https://forum.canton.network/u/stefanobaghino-da)\
**Post date:** [January 20, 2023, 2:14pm UTC](https://forum.canton.network/t/init-script-in-canton/6006/2 "2023-01-20T14:14:19Z")

</div>

Does [this](https://discuss.daml.com/t/how-to-pass-init-script-option-on-the-command-line/5942/3) help?

---

<div class="post-metadata">

**Author:** ![nagendra](https://avatars.discourse-cdn.com/v4/letter/n/9fc29f/32.png) [@nagendra](https://forum.canton.network/u/nagendra)\
**Post date:** [January 23, 2023, 7:15am UTC](https://forum.canton.network/t/init-script-in-canton/6006/3 "2023-01-23T07:15:37Z")

</div>

Hi @stefanobaghino-da ,

Thanks for your response. This works in a sandbox environment, i’m afraid it’s bit too much for production/prod replica environments as we’ll end up running the `daml script` command manually. I was able to figure out some stuff in the bootstrap script and it is working, but i’m not sure if it is right or not. Below is the script.

```haskell
import better.files._

val operator = participant1.parties.enable("Operator")
val operatorAssignment = Set(operator -> participant1)

// upload dar file to participants
val darPath = Option(System.getProperty("dar-path")).getOrElse("/.daml/dist/participant-${DAR_VERSION}.dar")
darPath.exists || sys.error(s"cannot find the dar file ${darPath}")
participants.all.dars.upload(darPath)

participant1.domains.connect_local(mydomain)
val operatorRolePackageId = participant1.packages.find("Role.Operator").head.packageId
val createRoleCommand = ledger_api_utils.create(operatorRolePackageId, "Role.Operator", "OperatorRole", Map("operator" -> participant1.parties.find("Operator")))
participant1.ledger_api.commands.submit(Seq(participant1.parties.find("Operator")), Seq(createRoleCommand))

```
