Moralis server is asking for master key

I’m trying to subscribe to transactions where a user is involved so I can create triggers on my platform, but when I try to sub, moralis is asking for my master key, which should be a secret.

This code is running in our front-end, and not as a cloud function, I was unable to return a subscription from a cloud function (and i think it isn’t possible)

const query = new (await getMoralis()).Query('EthTransactions')

await query.aggregate([
    // only transactions to or from userAddress
        match: {
            $expr: {
                $or: [
                    { $eq: ['$from_address', address] },
                    { $eq: ['$to_address', address] },

const subscription = await query.subscribe()
subscription.on('create', function(data) {


You may not be able to do an aggregation without master key

How can I do this without exposing the key? Should i be using cloud functions?

Maybe you can do a query without using aggregation

any idea on how i could use moralis to listen to in and out transactions of an address (wallet)?

You can watch an address and all the transactions for that address will be synced in your Moralis server db

In our platform, people can access wallets without owning them (watch only). Therefore we can’t ask them to sign a login message. Due to this, we can’t get our users registered in the database. Is there any other way to watch the transactions/register users in the database?

you can watch an address programmatically:

await"watchBscAddress", { address: "ADDRESS".toLowerCase(), "sync_historical":true })

Thank you, this worked!

But now I’m getting this error:


I got the “Matic” prefix at:

you can try with Polygon instead of Matic

That worked, thank you so much!

1 Like