Are canisters in a way like npm packages

Do canisters act like npm packages where like how I might not write my own image compression function and install an npm package that does that I would instead call somebody else’s canister and run a function in that canister that does that?

1 Like

that’s pretty much it, we call this “open internet services”. @enzo QR repo is a good example of this, if the methods of this canister are publicly available you could just call them instead of deploying your own QR functionality.

1 Like

ooohhh ok. So everything will essentially need transitioned from current npm packages to canisters in a perfect world or in the meantime like the image compression example would i just use a combination of an existing npm package for the image compression because there isnt a canisters yet and I would use the qr code canister for auth as well? Also on the canisters can the creator specify who can access it like if he/she wants it public for him/her but not for others. And for the economics of it would there be like an opperation fee paid to dfinity and an additional fee set by the owner to call his/her canister?

oh i don’t think so, i’d say npm packages stay npm packages (frontend) and motoko canisters stay motoko canisters (backend). i don’t think it makes sense to port all npm packages to canisters. to your second point: yes you as a creator could restrict access to your canister. currently it seems like the canister has to be loaded up with gas to function, the way you do this (charge people for using it or paying for it by yourself) should be up to you

1 Like

ok i wasn’t talking about calling npm packages from canistors I just mean I want to be able to take an image and compress it. Idk how to program that myself but there currently are npm packages that can help do that. Is it dfinity’s plan to have people start to rewrite these functions into canisters. Because of the benefits of canistors. However in such cases this early on where there arent many canistors I should simply resort to the “old” way of using npm until a canistor that completes my needs becomes available? Im just trying to properly understand a lot of this to help me build a map in my head of how apps should be built

It’s pretty open on how you choose to build things, you can use npm packages frontend, no problem there, or Motoko/Rust/other packages in your backend canister code if that’s where you want the logic, or a call to another canister entirely if that makes more sense, they’re all valid options. It would more depend on where you actually want things to run.

1 Like

Ya i guess more on the backend is probably best because it can’t be messed up with user doing something odd intentionally or accidentally. I think that’s best practice. Ok so I guess i never thought too in depth about npm packages. So I would create my app canister and I could import an npm package that is made with Rust/ Motoko/ languages that compile to webAssembly or any package? And these packages get fully copied into my canister right and have all the security because the functions get handled on the IC whereas calling from frontent runs the code on the clients computer correct? Where some hacker could just not send my actual matoko database the compressed photo but rather a large photo or idk malware stuff. I’m just using the photo thing as an example case but interested as it relates to everything.

i don‘t think there will be motoko/rust packages available for npm as it‘s (afaik) only just for js. but there is a package manager for motoko - vessel.

usually with code for the internet computer you can either decide to publish it as a module that other people import to their projects (like a npm package) or a canister that people can call into for certain functionality (like the linkedup socialgraph that could be THE socialgraph for the internet computer that all other social media applications use)

2 Likes

Oh ok. That’s helpful. I’m not very familiar with vessel of course but ill look more into it. Is it pretty new as well. Trying to find current state so I can decide where the greatest opportunity is for me to build. Maybe its not building an entire app rn but rather I could build some nice single purpose canisters or something. Hmmm idk

2 Likes

just go with the flow, we are all just experimenting here :slight_smile: this is all super new. if you have any further questions always feel free to ask!

1 Like