[SOLVED] watchAddressfrom code - master key required to perform this request

I am trying to add an address to sync and watch from code following an example I found on this forum.

Doing so still returns “master key is required to perform this request”.

Where am I going the wrong way here?

  let response = await Moralis.Cloud.run(
          "watchEthAddress",
          {
            address: this.address
          },
          { useMasterKey: true }
        );

that may mean that it didn’t have the proper master key set

the syntax is the following one:

x = async () => {
    const  Moralis = require('moralis/node')
    console.log(Moralis.CoreManager.get("VERSION"))
    await Moralis.start({ serverUrl: "https://adsfasdf:2053/server", appId: "gdsfgsdfg", masterKey: "sgfsdfg" });

    const results = await Moralis.Cloud.run("watchEthAddress", {address: "sgdfgsfg", syncHistorical: true}, {useMasterKey: true})
    console.log(results)

    }

x();

1 Like

Sorry, maybe I was unclear. I am trying to call that function from a front-end. I am not using Moralis/Node, I have imported Moralis in a vue application from which I want to submit an address to watch for.

Do I have to create a custom cloud function that I call from my front-end, which then calls a cloud function itself (from where a masterkey is available)?

yes, you can not call that from front end now because you wi’ll not have master key there

Ok so I always need a front end wrapper function in that case. Could you check then why I get the error that "Invalid function “watchEthAddress”?

This is my cloud code

Moralis.Cloud.define("watchAddress", async(request)=>{
  const logger = Moralis.Cloud.getLogger();
  logger.info("watchAddress called from front end")
  const address = request.params.address;
  
  if(!address) throw Error("no address provided");
  
  return await Moralis.Cloud.run("watchEthAddress",{address: address}, {useMasterKey:true});
  
});```

what it the server url where you are trying to run that?

https://kb5kpiz0r1ry.usemoralis.com:2053/server

we are going to make an update soon that we expect to fix that problem

1 Like

Ok. Do you have an ETA? In the meantime, not possible to add addresses to sync from the front-end by using Wrapper Cloud-Functions?

I guess that in less than an hour, you can try again now (I restarted something on that server), it may work but it may stop working again

1 Like

Is it something specific to my server instance? How can that occur?

I don’t think now that is something specific to your server

1 Like

Ok. I tried again, went through this time so I assume it is fixed. Thank you, I am really enjoying Moralis support response times.

What is a little bit confusing that the data populated by it in the collection now does not hold all the values (columns) that get populated by the usage of the plugin tho.

doesnt work on the 2nd attempt anymore. So I guess I have to wait until this is properly fixed.

yes, better to wait until it is properly fixed

not sure what you mean here

any update on this, or will I get pinged on here when it has been fixed / upgraded?

you can try to update now to a newer version of the server to see if it works

1 Like

It is adding the address to the collection now. Thank you