Trying to track an address

I’m trying to track an address following these instructions: https://docs.moralis.io/moralis-server/automatic-transaction-sync/historical-transactions#watch-address-from-code

I tried this:

  const results2 = await Moralis.Cloud.run("watchMaticAddress", {
    address: data.wallet,
    sync_historical: true,
  });

and got this error

Error: Invalid function: "watchMaticAddress"
    at handleError (D:\cost_basis_ab\node_modules\moralis\lib\node\RESTController.js:423:17)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async getWalletCostBasis (D:\cost_basis_ab\server5.js:230:20) {message: 'Invalid function: "watchMaticAddress"', code: 141, stack: 'Error: Invalid function: "watchMaticAddress"
…iReturn Code\cost_basis_ab\server5.js:230:20)'}

I also added this address through the Moralis admin. It says it is “currently synching” but in the dashboard, only a few Eth transactions are showing up. No Polygon txs.

Also tried to run a job to sync the polygon txs.

Thanks - you are using this address 0x704111eDBee29D79a92c4F21e70A5396AEDCc44a ?

@cryptokid will help you when he is back in the morning

Yes. That’s one test wallet

@jswift24

please go to https://beta.moralis.io
login with your normal email and password
create a new server using beta branch

Select Polygon as network

add “Sync and Watch Address”

wait maybe 30 seconds

Screenshot 2022-01-09 at 23.41.20

you will see them popup

I just tried with that address

Try - and report back!

Thank you. Here are my test results:

  1. In the sync/watch-address configuration screen, if you pick all chains, it only syncs fantom. Looks like it can only watch one chain for one address at a time.
  2. If you then “edit” it and uncheck fantom, check polygon, hit save, it doesn’t save. Still stuck on fantom. The only way to get back to watching polygon is to delete and watch a new address/chain.
  3. After getting through the above, I managed to get the transactions synced into the dashboard. Now our code runs without the rate limit. Thank you!

Does this mean that if I’m fetching items from Moralis/mongo DB, this does not count against the rate limit?

Our app is supposed to work for any user that provides their wallet address (but does not necessarily log in through metamask). Can I add them to the Moralis DB through the code?

Thanks @jswift24 yes it’s still beta thanks for feedback we will fix

have you tried to use watchMaticAddress from Cloud Functions? https://docs.moralis.io/moralis-server/cloud-code/cloud-functions

Indeed - syncing using the server is outside rate limits

OK. If I do that and it takes ~30sec for a new user, I’d like to show them something like a “loading…” progress bar. Is that possible?

Does this cloud function return an event when finished?

Also, our development cycle is still impacted: The first time I run the code, all is well. The second time I run it (a second later), I get errors like this:

get token transfers error {
  code: 141,
  error: 'Too many requests to Web3API from this particular client, the clients needs to wait before sending more requests. This can be adjusted using Moralis.settings.setAPIRateLimit. Read More: https://docs.moralis.io/moralis-server/web3-sdk/rate-limit.'
}

I read the that article but it’s pretty unclear. I would like to eliminate the client-side rate limit during the dev cycle. How do I do that? If the limit cannot be eliminated, what is the highest setting I can have?

Client side rate limit can be changed here https://docs.moralis.io/moralis-server/web3-sdk/rate-limit

Check columns in WatchedPygonaddresses maybe you see status there

Will be back in the morning

Thanks. I read the that article but it’s pretty unclear. I would like to eliminate the client-side rate limit during the dev cycle. How do I do that? If the limit cannot be eliminated, what is the highest setting I can have?

Also, I tried this:

Moralis.settings.setAPIRateLimit({
  anonymous: 1000,
  authenticated: 20,
  windowMs: 60000,
});

and got this error:

Moralis.settings.setAPIRateLimit({
                 ^

TypeError: Cannot read properties of undefined (reading 'setAPIRateLimit')
    at Object.<anonymous> (D:\Documents-Alon\DefiReturn Code\cost_basis_ab\server5.js:39:18)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47

You need rate limits always as anyone can call Web3API using the SDK on your site and it will
Be counted against your API plan

You put that code in cloud function

You can set rate limit very high - we don’t have a way to remove it fully

  1. I thought accessing things through the mongo db doesn’t count against my rate limit.
  2. I tried to raise the client limit using the code above, please let me know tomorrow what I’m doing wrong.

@jswift24, can you share your server url/subdomain? maybe that server is an older version.

for sync, yes, it only works to sync one address on one chain per request in the interface

the syntax that should work is watchPolygonAddress

  1. using Moralis.Web3API in the SDK is using API not Mongo and that goes against your plan, if you want to read mongo using SDK you use database queries https://docs.moralis.io/moralis-server/database/queries

  2. What is the error? you didnt run in cloud function before as you run locally?