How to install frontend using managment canister?

I need to do this via management canister install_code function.
I am able to upload a backend wasm on a canister by calling management canister.

I am not sure how the frontend can be installed ?
I see frontend creates two wasm files one with name storage.wasm and the other is .wasm
Also there exists asset forlder.

What dfx does when installing frontend code to canister, how this can be achieved via management canister interface ?

1 Like

I recommend you look at the file setup created by dfx new. It should answer quite a few questions already.

Dfx uses the asset canister to provide the frontend. It first uploads the generic asset canister using the management function install_code, which has been pre-compiled. Then, it uploads the frontend assets to the asset canister. This step happens through normal update calls and cannot happen via management canister calls. Otherwise the assets would have to be hard-coded and compiled into the asset canister.

@Severin Where can I find the dfinity hosted wasm of asset canister ?

I don’t think there is a proper hosted wasm. AFAIK we always build it manually (build script here) when we update it in dfx. If you want an ugly hack version of a hosted asset canister (please don’t), you can download the latest version that’s bundled with dfx from the dfx repo here: sdk/assetstorage.wasm at master · dfinity/sdk · GitHub

What’s wrong with it. I started to use that assetstorage.wasm. What do you do wrong?

It’s pointing to a place where the wasm just happens to be. It’s possible that the file gets moved, renamed (e.g. to assetstorage.wasm.gz) or that it’s interface changes without any warning. And it’s more likely to contain bugs than offical release versions.

If you’re fine with that risk, then go ahead, but I can’t in good conscience recommend it with a blanket statement

1 Like