[SOLVED] Event Sync did not sync historical

Hi,

I’ve added some syncs events but did not bring the historical data. This functionallity should work with all the contracts?

Info:

Network: AVAX testnet / mainnet (I tried both)

contract address

0x9450A29eF091B625e976cE66f2A5818e20791999

Topic

AnswerUpdated(int256,uint256,uint256)

ABI

{
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "int256",
                "name": "current",
                "type": "int256"
            },
            {
                "indexed": true,
                "internalType": "uint256",
                "name": "roundId",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "updatedAt",
                "type": "uint256"
            }
        ],
        "name": "AnswerUpdated",
        "type": "event"
    }

Regards

you shouldn’t add spaces in the topic

My bad copying it, but I didn’t create it with the space, I even tried again to be sure.

I think that It shouldn’t be int256

If you do sha3 with web3 in the topic text it should result the hash for topic0 that you see in block explorer for a transaction

Hey @teterabOb, did you solve it yet?

Why you think it sould not be int256? if the explorer and contract code shows that is int256.

Hey @YosephKS not ney, I tried all the paramaters as uint256 but still does not bring historical data

Hi please provide

Your Server url
Link to some tx where this event happened

Hey @teterabOb, just saw you event contract in AVAX C-Chain, can you change you topic instead to this 0x0559884fd3a460db3073b7fc896cc77986f16e378210ded43186175bf646fc5f, I got this topic from snowtrace. If still not fixed, then do what @ivan said so we can help more~

it looks like this is the right topic

x = Web3.utils.sha3('AnswerUpdated(int256,uint256,uint256)')
=>
'0x0559884fd3a460db3073b7fc896cc77986f16e378210ded43186175bf646fc5f'
1 Like

I’m testing now with that specific contract

it looks like the fix is to use a modified version of that abi:

{
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "int256",
                "name": "current",
                "type": "int256"
            },
            {
                "indexed": true,
                "internalType": "uint256",
                "name": "roundId",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "updated",
                "type": "uint256"
            }
        ],
        "name": "AnswerUpdated",
        "type": "event"
    }

mainly "name": "updated", instead of "name": "updatedAt", so that field is not interpreted as a date

Thanks guys @YosephKS , @ivan . It finally worked as @cryptokid said, changing the abi and topic with the modifications he shared.

For everyone who wants to sync the aggregators provided by Chainlink using moralis should use the following topic and abi:

AnswerUpdated(int256,uint256,uint256)
{
        "anonymous": false,
        "inputs": [
            {
                "indexed": true,
                "internalType": "int256",
                "name": "current",
                "type": "int256"
            },
            {
                "indexed": true,
                "internalType": "uint256",
                "name": "roundId",
                "type": "uint256"
            },
            {
                "indexed": false,
                "internalType": "uint256",
                "name": "updated",
                "type": "uint256"
            }
        ],
        "name": "AnswerUpdated",
        "type": "event"
    }

Thanks a lot !

1 Like