SNS Updating the frontend asset canister?


I was wondering how to make a proposal that updates the contents of the SNS-1 asset canister.
Correct me if I am wrong, but I am left with the impression it’s made so developers can mess with it however they want, so that’s what I want to do.

I’ve made this blast with the basics needed for someone to connect to the SNS-1 canisters.
[Internet Computer Content Validation Bootstrap]

Canister ids weren’t public, so I had to reverse the public Swap canister Principal into a Nat and poke around it to find them all.

I can’t seem to find a way to update the assets, because they are held by the asset canister and the governance canister seems to be able to only change the whole wasm, but not the asset canister contents. I can propose an update of the whole wasm, but that’s not what I am going for.

I would like to know how it can be done if it can be done at all without more SNS upgrades.

What I will do is, make a proposal with something fun, which probably won’t get accepted, or if it gets accepted will last for a few days until someone else votes and changes it.


Hey @infu!
The SNS-1 canister: sqbzf-5aaaa-aaaam-aavya-cai is an asset canister. Here you can see the simple ‘store’ method:

// Single call to create an asset with content for a single content encoding that
// fits within the message ingress limit.
  store: (record {
    key: Key;
    content_type: text;
    content_encoding: text;
    content: blob;
    sha256: opt blob
  }) -> ();

To upload a frontend file, the governance canister must call the asset canister to upload the file. To get the governance canister to call the asset canister, we first make the proposal to AddGenericNervousSystemFunction, which is like adding a new proposal type that uploads files to the asset canister.

Then once that is done, we can make an ExecuteGenericNervousSystemFunction proposal that will make the governance-canister call the asset-canister’s store method with a payload of the frontend asset candid parameter for the ‘store’ method.

For the AddGenericNervousSystemFunction proposal, there needs to be a validator method that the governance canister calls to validate that the ExecuteGenericNervousSystemFunction-proposal’s payload is well-formed, prior to putting the ExecuteGenericNervousSystemFunction-proposal up for a vote. ic/ at cbd16d23c673115d45ac902376ec194fc623611a · dfinity/ic · GitHub

I made a canister for this validation method: epeco-piaaa-aaaai-qatka-cai with the following source code:

use ic_cdk_macros::{query};
use serde_bytes::ByteBuf;
use ic_cdk::{
        candid::{CandidType, Deserialize}

pub type Key = String;

#[derive(CandidType, Deserialize)]
pub struct StoreArg {
    pub key: Key,
    pub content_type: String,
    pub content_encoding: String,
    pub content: ByteBuf,
    pub sha256: Option<ByteBuf>,
    pub aliased: Option<bool>,

pub fn validate_store_file_payload(_q: StoreArg) -> Result<String, String> {
    Ok("Payload looks good!".to_string())

The method: validate_store_file_payload will trap if the StoreArg parameter is incorrectly encoded, and will return an Ok() if the payload is valid. This is due to the #[query] macro decoding the payload into a StoreArg.
The source code for the epeco-piaaa-aaaai-qatka-cai canister is here: sns-1-epeco/ at master · levifeldman/sns-1-epeco · GitHub.
I made the SNS-1’s root canister: zxeu2-7aaaa-aaaaq-aaafa-cai into the sole-controller of the epeco-piaaa-aaaai-qatka-cai canister, so now it is part of the SNS-1. Canister: epeco-piaaa-aaaai-qatka-cai - IC Dashboard see the Controllers section. Also see the SNS-1’s-root canister here: Canister: SNS-1 Root - IC Dashboard, click list_sns_canisters, call, and see the epeco-piaaa-aaaai-qatka-cai canister is part of the SNS-1.

The first proposal AddGenericNervousSystemFunction to add the upload-asset proposal-type is live! See here on the SNS-1 Governance canister! click on the list_proposals method, limit: 10, and click ‘call’:

Vote here on open-chat!


@levi @infu love the initiative you’ve taken here to get things rolling!

I think this might be a bit of complex first proposal for the general SNS-1 community to digest though. We’d had in mind trying of a “hello world” motion proposal, to get everyone setup voting before embarking on dapp upgrades but you beat us to it :slight_smile:

There’s an increasingly active SNS-1 OpenChat group forming on OpenChat OpenChat: Decentralized chat on the Internet Computer

Maybe you’d like to drop by there too and explain what you’re up to? Not everyone on the SNS-1 community is on the forum.

Voting can also be done on OC using the SNS-1 proposals bot OpenChat: Decentralized chat on the Internet Computer



Thanks for taking the time to explain in detail and make this!

The new function added is tied to the asset canister and a specific method and it can’t do anything else, but change the contents. And also that function can be executed only with a proposal. Correct?

Looks like @levi beat me to making the first proposal :1st_place_medal:

I told my artist to draw a cute character for the SNS-1. I am thinking of making a proposal to add it to the existing page. This will be some kind of decentralized token-powered art collaboration :smiley: I won’t mind if it’s rejected. After all, it’s governed by ~4500 individuals with their own views and I don’t think anything like that was done before while connecting it to a webpage.

1 Like

Correct. On the dashboard SNS-1 governance canister, click list_proposals limit: 10, look at the proposal and look at the sns-governance source code for what the action AddGenericNervousSystemFunction does.

1 Like