It says invalid function âwatchEthAddressâ . Even the code copied from the docs isnât working âŚ
this is an example that works, I tested it today:
const results = await Moralis.Cloud.run("watchEthAddress", {address: address, sync_historical: false}, {useMasterKey: true})
but you can not run it in front end, you could run it in cloud code, as it requires master key.
if a user authenticates with metamask, then you donât have to add that particular eth address to watch because it will be synced automatically
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");
const result = await Moralis.Cloud.run("watchEthAddress",{address: address, sync_historical: false}, {useMasterKey:true});
return result ;
});
This is the code is use as cloud function and when I pass the address from the front end it says invalid function âwatchEthAddressâ .
As you said âif a user authenticates with metamask, then you donât have to add that particular eth address to watch because it will be synced automaticallyâ. so you mean that I donât need to run the above code for every individual user if the use metamask login to access my app ?
-
I have been using Metamask login for past one month but I couldnât get the transaction history !
-
Is it available only for the paid version ?
My computer science degree is in your hands am building my final semester project using moralis.
that functionality is available for every server.
what is the server url?
did you update the server recently and it is a nitro server with coreservices plugin?
yes, that is a nitro server, and it seems to be updated
what evms/chains did you enable for that server? you can find that information in admin interface
Poylgon mumbai and avax testnet
try to enable also an eth chain if you want to add to watch an address on eth
Thatâs okay but the problem is that the cloud functions says watchXxxAddress is invalid
(irrespective of any chains)
you tried with other chains too?
you tried with watchEthAddress only here?
`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â);
const result = await Moralis.Cloud.run(âwatchXxxAddressâ,{address: address, sync_historical: false}, {useMasterKey:true});
return result ;
});`
that is not how it should work, you have to replace watchXxxAddress with the chain where you want to add that watch, for example on eth is watchEthAddress
Yes I have done so just for the example I have shown⌠But while defining in the cloud function I did the way you mentioned⌠you could have seen in that output.
try to enable an eth chain first, then try to use watchEthAddress, also try to enable bsc chain if you try watchbscaddress, for matic you can try watchPolygonAddress
Oh man. I have been tryin with watchMaticAddress instead of watchPolygonAddress. Please update the same in the docs also.
So for each new user I need to run the code (add to the watchlist) so that I could monitor their transactions right ?
if the user authenticates with metamask, you donât need to run that code, unless you also want full history of the user transactions
So you mean that if an user authenticate with metamask then Moralis itself shows the transaction data without explicit invocation of cloud function ? But in my case its not showing the transactions ? Should I enable anything ?