Motoko Playground - issue with classes example and cycles

I tried to use the Playground for developing an app where I create canisters using actor classes and could not create the canisters because of no cycles in spite of the fact that I used Cycles.add() function. I than tried the classes example (Buckets) and ran into the same issue. I used the example from Claudio specifically claimed to work with cycles (Claudio/classes by crusso · Pull Request #95 · dfinity/examples · GitHub) but it did not work. Here is the link to the code in playground: Motoko Playground - DFINITY
Am I doing something wrong? Or is there a limitation in the playground?

It’s a limitation of the playground. Canisters deployed with that cannot send their cycles somewhere else; this restriction is put it to prevent people from abusing the playground as a source for free cycles. In other words, Cycles.add() doesn’t do anything. But installing another canister would require that.

3 Likes

Thank you Joachim. I understand the issue. I guess playground mainly intended for testing very simple projects. As a Windows user I would prefer using the playground for testing, rather than switching from and to Ubuntu.
I would however believe that there should be a way to make canister creation from an actor class possible without allowing cycles to be transferred to other canisters.

We have a plan to allow users to use their own wallet for deployment. In that case, you can freely create new canisters, because you are paying for cycles. But it can take some time to implement this.

For Windows platform, I think you can also use WSL to run dfx and moc?

1 Like

Thanks chenyan. With WSL I would be missing the code highlighting and code analysis of playground and vscode.

VScode actually integrates with WSL really well using its remote connection feature, there’s a guide to setting it up here: https://forum.dfinity.org/t/dfx-on-windows-for-beginners/194/13

You’d need to install the Motoko plugin alongside the WSL remote plugins, then you’ll have type checking and syntax highlighting as normal.

There are a few more WSL setup tips here too: https://forum.dfinity.org/t/native-windows-support/1241/2?u=ori

Thanks Ori. This is great.

Any chance to update the playground so it is able to use .HashMap vals() function?