Why some method update are rejected from local version?

Hello all, I use the svelte-motoko-starter projet.
After 2 days, it became a battle… and the more time I spend, the less I can give up. Now I’m one millimeter away from success :clown_face:

I’m trying to use the Auth.svelte file to make some calls in local.
So, in my main.mo, i have :
From : http://rkp4c-7iaaa-aaaaa-aaaca-cai.localhost:8000/ OR

1st working example :

public query func test1() : async Text{
	return "Hello";

2nd working example:

Now, this doesnt work… (but if I add query keyword, as I should, it works)

But… If i deploy the code on Live icp, it works (even without query keyword), and it also works on the npm run dev interface localhost:5000 …

For the update method, without query, it seems to properly write data, but I got the error.
It seems possible to work but i don’t really like to have this in my terminal and I can’t know if it could make other errors later.

Don’t break your head too much for this, but in case you have a quick idea… I will be happy.

I don’t have the reference from the doc right here and did not search through the forum but basically, to give you a really short answer, query calls cannot modify the state of the canisters, only update calls can.

It has to do with security, persistance etc. worth having a deeper look but just wanted to give you a short feedback.

Thank you, yes, that’s why I mentionned the problem only occur with update methods…
It doesn’t explain why it works with localhost:5000 adress on in live on the mainet… … No problem, I’m finally going back to continue my project like this.

Oh my bad, I misunderstand your question and skipped the error message.

So if I get it right, it does not work because of the error printed above Fail to verify certificate.

I think this happens often locally when the fetchRootKey is not called for local development. Do you do so?

agent.fetchRootKey().catch(err => {
      console.warn("Unable to fetch root key. Check to ensure that your local replica is running");

where you create the actor is there?

if your project is open source, I can quickly clone it and have a look if you want.

I don’t use the fetchRootKey, I doesn’t really understand what is it and how to use.
I think I can work a little like this for now. If I spend another hour debugging, I’ll definitely give up everything. I’ll probably come back to this later and send you the project if needed. Thank you very much.

fechtRootKey is needed for local development. when you want to call your local replica - started with dfx start - agent js will need to validate the certificate which is initialized with fechtRootKey

long story short, to develop locally - and locally only - fechtRootKey needs to be called


Thank you ! I missed this part. :heart:

1 Like