Actor Class Management

Can anyone help me with proper syntax for upgrading a canister from inside Motoko as mentioned in Language quick reference | Internet Computer

I’m able to see the system module inside actor class but how to use #new, #upgrade, etc?

Sorry, this really need better documentation, but there some examples for you here from out test-suite:


There’s also an example of upgrading the nodes of a distributed map here:

@kentosugama gave a demo here:

I think it starts around 1h:06m

Here’s the link to the code Kento was demoing:

The crucial line for doing an upgrade looks like this:

await (system Buckets.Bucket)(#upgrade oldBucket)() 

Buckets is the library containing the class, (#upgrade oldBucket) is the instruction to upgrade the oldBucker actor (of some actor {} type), finally () are the arguments to the class (in this case just a trivial empty tuple, but could be something more interesting, depending on the definition of the actor class).

Hope that helps,

PS. We really need to document this better.

1 Like