Which is the best way to set admin to your application?

Hello everyone!

Would you please suggest an example to create admin/admins to your application?
Thank you!

This is something the platform makes very easy, you can just grab the caller of a public method and run a check on it to allow admin-only access, eg:

public shared(msg) func doSomething() {
    if (isAdmin(msg.caller)) {

msg.caller there is of type Principal. You could either store this Principal in an array/set of admin Principals, or you could have an admin status flag in the user’s profile. The isAdmin() function above could check for either of these.

A couple of examples from project repos: