So, i just want to create a canister to storage images, used the assets type, but throw error when deploying to ic.
Correct.
dfx
always executes that command npm run build
for canister with type assets
in dfx.json
.
Technically, when you choose type="assets"
, dfx
uses compiled wasm from certified_assets repo
It is assumed that there is a frontend in this folder and it needs to be builded for convenience.
If you want to deploy certified_assets
canister separately from frontend, you can try
{
"canisters": {
"your_awesome_images_storage": {
"type": "custom",
"candid": "PATH_TO_CERTIFIED_ASSETS_DID/assets.did",
"wasm": "PATH_TO_CERTIFIED_ASSETS_WASM/assets.wasm"
}
},
"defaults": {
"build": {
"packtool": ""
}
},
"dfx": "0.8.4",
"version": 1
}
Certified_assets is a rust canister for keeping any assets. You can build them locally and get .wasm
file (.did
already included in the repo)
UPDATE
Troubleshooting:
For interact with your canister use
dfx canister --wallet $(dfx identity get-wallet) YOUR_COMMANDS
Or do not forget to authorize you local identity before manually interaction
dfx canister --wallet $(dfx identity get-wallet) call $(dfx canister id your_awesome_images_storage) authorize $(dfx identity get-principal)
dfx canister YOUR_COMMANDS
Because canister is deployed under your wallet and only wallet is authorized to canister after deploy
UPDATE END
OR you can use as temporary
- Add
package.json
in your canister folder with emptybuild
command - Fairly switch canister type to
type="assets"
indfx.json
dfx deploy
- Profit
It is not recommended, but works.
Yeah, I empty the build
command currenctly, i will try the custom
canister type later.Thanks for your answer.