Sync contract events in real time

i to all, i have recently started studying moralis
i’m running the guide “Moralis Programming Basics - Sync contract events in real time”, all the things i’ve done so far have gone well :slight_smile:
i have a personal Ubuntu server with static ip address on which have correctly installed ganache and truffle and i have perfectly executed the moralis guide to login/logout with metamask and also the one to create a “monster” in the database :slight_smile:
Everything appears in my dashboard, a sign that the connection between my moralis server and my ubuntu server where i installed ganache and truffle works.
Following the guide “Sync contract events in real time” i perform all the steps, including the creation of the plugin, and when from the truffle console i deploy and i issue the event for example with the command

await contract.TestFunction(16,“Pippo”)

i see in the ganache log that everything happens correctly.
The problem is that the table is created in the database, but no events are written :frowning:
What do i need to configure to ensure that the event performed remotely on my ubuntu server connected to moralis is recorded in my dashboard?

Hey @Aliberto

Could you share your cloud function listener?

yes, i have only this one

Moralis.Cloud.define(“getAvgGas”, async function (request) {
const query = new Moralis.Query(“EthTransactions”);
const pipeline = [
{
group: {
// group by “from_address”
objectId: “$from_address”,
// add computed property avgGas
// get average and convert wei to gwei
avgGas: { $avg: { $divide: ["$gas_price", 1000000000]} },
},
},
{ sort: { avgGas: -1 } }, // sort by avgGas high to low
{ limit: 10 }, // only return top 10 results
];

// the master key is required for aggregate queries
const results = await query.aggregate(pipeline, { useMasterKey: true });
return results;
})

Hi,
How did you add that event in the plugin? you have to use exact topic and ABI for it to work properly.
Also how is that event defined?

this is the contract source code

pragma solidity ^0.8.0;

contract TestContract {
event TestEvent(uint256 amount, string name, address account);

function TestFunction(uint256 amount, string calldata name) public {
    emit TestEvent(amount, name, msg.sender);
}

}

this is the ABI

{
“anonymous”: false,
“inputs”: [
{
“indexed”: false,
“internalType”: “uint256”,
“name”: “amount”,
“type”: “uint256”
},
{
“indexed”: false,
“internalType”: “string”,
“name”: “name”,
“type”: “string”
},
{
“indexed”: false,
“internalType”: “address”,
“name”: “account”,
“type”: “address”
}
],
“name”: “TestEvent”,
“type”: “event”
}

Last time it worked for me I used a topic something like TestEvent(uint256,string,address) instead of TestEvent(uint256,string,address);, but I don’t know if this is the problem.

nothing, tested without “;” but what if I tried to do it from script?

you could try to add entries to a table from a script, if you really want to do that