[Solved] StreamSync self hosted Parse Server

Hi,

Back when Moralis had servers, I had a project set up with syncs to log contract events to our mongoDB in a specific place. Now that weā€™re switched over to a self hosted parse server, I am trying to recreate what we once had.

This is in my index.ts:

app.use(
	streamsSync(parseServer, {
		apiKey: config.MORALIS_API_KEY,
		webhookUrl: config.STREAMS_WEBHOOK_URL,
	})
);

After I triggered an event ā€œoptionCreatedā€ on the smart contract, I got one entry in each of the two tables:

  • [MumbaiTestnetLogs]

_id
"rTyoUEbOJk"
name
"optionCreated"
logIndex
18
transactionHash
"0xfe9b6c22e1b2e0d80a3ee975aba91243d493b928a8ac358de4808659323a3aa9"
address
"0x0b30be28c6b359ad5e8804ae587b12b46403a7b0"
blockHash
"0xf5c6fe838edd8067dd1995b70f696767bd5a0d3ffe29e9b68eb38bc563b0551a"
blockTimestamp
1689216833
blockNumber
37871316
confirmed
true
chainId
80001
sender
"0xd896aea7e5865d2d12534702b3371e2c5ce5bc8b"
_created_at
2023-07-13T02:53:55.193+00:00
_updated_at
2023-07-13T02:58:11.123+00:00
  • [MumbaiTestnetTxs]

_id
"QzKypUg3A4"
hash
"0xfe9b6c22e1b2e0d80a3ee975aba91243d493b928a8ac358de4808659323a3aa9"
chainId
80001
transactionIndex
7
gas
187840
gasPrice
1500000016
nonce
161
fromAddress
"0xd896aea7e5865d2d12534702b3371e2c5ce5bc8b"
toAddress
"0x0b30be28c6b359ad5e8804ae587b12b46403a7b0"
value
"0"
input
"0x15a921a000000000000000000000000000000000000000000000000000000000ee6bā€¦"
type
2
receiptStatus
1
receiptGasUsed
187840
receiptCumulativeGasUsed
1705292
blockHash
"0xf5c6fe838edd8067dd1995b70f696767bd5a0d3ffe29e9b68eb38bc563b0551a"
blockTimestamp
1689216833
blockNumber
37871316
confirmed
true
_created_at
2023-07-13T02:53:55.218+00:00
_updated_at
2023-07-13T02:58:11.120+00:00

Hereā€™s the abi for ā€œoptionCreatedā€:

{
    "anonymous": false,
    "inputs": [
      {
        "indexed": false,
        "internalType": "address",
        "name": "sender",
        "type": "address"
      },
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "_optionId",
        "type": "uint256"
      },
      {
        "indexed": false,
        "internalType": "uint256",
        "name": "_price",
        "type": "uint256"
      },
      {
        "indexed": false,
        "internalType": "uint32",
        "name": "_quantity",
        "type": "uint32"
      },
      {
        "indexed": false,
        "internalType": "uint128",
        "name": "_mintableDate",
        "type": "uint128"
      },
      {
        "indexed": false,
        "internalType": "string",
        "name": "_uri",
        "type": "string"
      }
    ],
    "name": "optionCreated",
    "type": "event"
  },

However, there are two main issues: all of the data from the contract event is not there / subsequent transactions are not being logged. Every time i trigger an event now, I get this error in my backend

2023-07-13T03:35:04.165553+00:00 heroku[router]: at=info method=POST path="/streams-webhook" host=lp-backend.herokuapp.com request_id=1e74677a-ee82-4eea-ba84-eeb8144bc744 fwd="44.226.155.103" dyno=web.1 connect=0ms service=4ms status=500 bytes=298 protocol=https
2023-07-13T03:35:04.165427+00:00 app[web.1]: error while inserting logs no matching event (argument="topichash", value="0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", code=INVALID_ARGUMENT, version=abi/5.7.0)

Any advice would be greatly appreciated

What data is missing?

the missing data is from the optionCreated event, namely sender, _optionId, _price, _quantity, etc.

Sender is included here. For the others to be included you need to edit the abi and remove _ from the names

_uri -> uri

in moralis dashboard?

Also, I dont believe this fixes the issue that the streams no longer are working

hi, did you try to set up a new stream with the new abi?
Also you will have to use a different name for the tag to not have a conflict with the previous created tables

I added the new ABI and i am still getting the errors

at=info method=POST path="/streams-webhook" request_id=621f7a30-5c62-4937-b015-bb7abcb04580 fwd="44.226.155.103" dyno=web.1 connect=0ms service=5ms status=500 bytes=298 protocol=https

error while inserting logs no matching event (argument="topichash", value="0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63", code=INVALID_ARGUMENT, version=abi/5.7.0)

by looking in a block explorer for this transaction hash I see that the topic0 is 0x81ee4c4b435dfa2750449f873b31266b4a4daf013d1f0eb47796e2f23ef55593

Iā€™m not quite following

where from is this topic hash?

Not quite sure what you mean

this error, where it is from, where from is that topic hash?

The error is from my server logs. not quite sure anything about it. I get it everytime streamSync is hit

LogFeeTransfer (index_topic_1 address token, index_topic_2 address from, index_topic_3 address to, uint256 amount, uint256 input1, uint256 input2, uint256 output1, uint256 output2)

=>
it has this topic0: 0x4dfe1bbbcf077ddc3e01291eea2d5c70c2b422b415d95645b9adcfd678cb1d63

it looks like it is trying to process an event for LogFeeTransfer

you can see the events here with the name ant topic0:

https://mumbai.polygonscan.com/tx/0xfe9b6c22e1b2e0d80a3ee975aba91243d493b928a8ac358de4808659323a3aa9#eventlog
```

This is what I need, but its not getting placed into my MongoDB

Here is stream-id: 1ea721cd-c51d-448b-b575-11e7746ad256 @cryptokid

it looks like you have this stream id: 1ea721cd-c51d-448b-b575-11e7746ad256

that has these settings:

 "topic0": [
        "minted(address,uint256,uint256,string)",
        "optionCreated(address,uint256,uint256,uint32,uint128,string)",
        "photographerPaid(address,uint256)",
        "referralPaid(address,uint256)",
        "TransferSingle(address,address,address,uint256,uint256)"
      ],
      "allAddresses": false,
      "includeNativeTxs": true,
      "includeContractLogs": true,
      "includeInternalTxs": true,
      "includeAllTxLogs": true,
      "getNativeBalances": [],
      "triggers": [],

it looks like that steam id has that

enabled, meaning that you will receive all the logs from a transaction, and you donā€™t have all the events in that abi, that LogFeeTransfer is missing from the abi and you will receive it and you will not know how to process it