[SOLVED] Event sync not working on BSC, or am I doing something wrong?

Hi,

I have NodeJS code running server-side, monitoring the PairCreated event on PancakeSwap’s 0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73

Event:
PairCreated(address indexed token0, address indexed token1, address pair, uint)

ABI:
{
“anonymous”: false,
“inputs”: [
{
“indexed”: true,
“internalType”: “address”,
“name”: “token0”,
“type”: “address”
},
{
“indexed”: true,
“internalType”: “address”,
“name”: “token1”,
“type”: “address”
},
{
“indexed”: false,
“internalType”: “address”,
“name”: “pair”,
“type”: “address”
},
{
“indexed”: false,
“internalType”: “uint256”,
“name”: “”,
“type”: “uint256”
}
],
“name”: “PairCreated”,
“type”: “event”
}

When I use NodeJS’s ethers library to monitor (connecting to a BSC mainnet speedy node), I receive the events as expected.

When I setup a sync using the same ABI/event/address, I get nothing, the database remains at 0 documents.


It’s set to sync to the table “tokens”

I can see the sync data in the EventSync table, but nothing in the tokens table.

What am I doing wrong?

at least the topic is not the right one, it has to have only the types of variables, you could use the hash version of the token too

1 Like

Looks like this was part of it.
When I created a new sync using only the types in the topic, it told me I had to create a filter otherwise there is too much data streaming in (a couple every minute on avg), a message I didn’t get before.

I’m still not getting any data in the table tho, but the filter looks correct?

{
“or”:[
{“eq”:[“token0”,“0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c”]},
{“eq”:[“token1”,“0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c”]}
]
}

I am getting pairs matching that filter when using speedynode:
(token0, token1, pair)

PairCreated 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c 0xcE34AEbCcD4f17Ba8441eA00b52648ae4D492F9F 0xC2118Ab6a103757f4616146ded0D419Ce66ec9C7

PairCreated 0x435e89775c93e46Ee0f2427Ab275cBb0df4c6a2D 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c 0x11a164a6f363D1146B2677f6747d196Cb0B82110

PairCreated 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c 0xd5Af20e45562153f5aF48143Bb97987FD073F94E 0x77a3D9468c730D89c3D560E77F64dD7CA380dBBF

Solved.

It turns out the addresses are always converted to lowercase.

So while in my non-moralis code (via ethers lib in nodejs) I get the address with some uppercases, in Moralis the same event returns the addresses in lowercase, which made my filter invalid.

Once the addresses in my filter got converted to lowercase, the sync started working.

Another note is to name the unnamed inputs in the ABI. Here the last input’s name was an empty string.

1 Like