How to save Logs/Events to DB in self-hosted server

“Sync-on-chain-data-to-the-database” only contains parse setup, how can I save new events from contract to db

can you give more information about what you want to do?

you set up a webhook url, you receive the events in the webhook url and after that you can save that received data in your preferred database

@cryptokid I’ve created a new stream on the website and did setup of parse-server, but it is not saving those events in db.

you want to use parse server for that?

you can try to do some debugging to see what happens, to see if you receive the data, to see why it is not saved

I just want to know how can I save events from contract to db in self hosted server, I don’t have a Moralis hosted server so migration will not be used here?

@cryptokid please check above

I don’t know the context. What did you do by now?

@cryptokid I’ve created a stream and added webhook, now when the webhook is called the “req.body” is undefined.

I want to receive that data and save it to db.

How you you read that req.body? You receive anything with that webhook request?

@cryptokid I’ve just created a simple express server of which endpoint/webhook I’ve added to the stream, when an event is emitted on the contract, there is a request to the webhook but nothing in the req body

ok, it should work fine with an express server, did you test it with a webhook url from webhook.site to see how the incoming request is expected to look like?

maybe print more info, like the http header, do you see info for the http header?

@cryptokid does the stream return events? Is it in the logs? How can I decode that, web3 decodeData doesn’t work on it, please refer to the following data retrieved from moralis

{
confirmed: true,
chainId: ‘0xa869’,
abi: [
{
anonymous: false,
inputs: [Array],
name: ‘Deposit’,
type: ‘event’
}
],
streamId: ‘24a34e56-cc65-4b63-a371-7d73488454f5’,
tag: ‘XANAOWB’,
retries: 0,
block: {
number: ‘16582414’,
hash: ‘0x7b5e8cf8416d022bb8cf8a21406001c5383a44163848e59b26f1fddae5411855’,
timestamp: ‘1670249621’
},
logs: [
{
logIndex: ‘2’,
transactionHash: ‘0xe03334f0be8c798c4e44941b7dfe78069f945ac590669ddf761062a37ae9c0f5’,
address: ‘0xa193b32dee0f33c80b88e27cefae39b5a8fd3990’,
data: ‘0x000000000000000000000000c969dc0b07ace3e99d6c2636e26d80086a90b8470000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000638dfc95000000000000000000000000000000000000000000000000000000000000002c’,
topic0: ‘0x36af321ec8d3c75236829c5317affd40ddb308863a1236d2d277a4025cccee1e’,
topic1: null,
topic2: null,
topic3: null
}
],
txs: [
{
hash: ‘0xe03334f0be8c798c4e44941b7dfe78069f945ac590669ddf761062a37ae9c0f5’,
gas: ‘98461’,
gasPrice: ‘26000000000’,
nonce: ‘84’,
input: ‘0xb6b55f250000000000000000000000000000000000000000000000000de0b6b3a7640000’,
transactionIndex: ‘0’,
fromAddress: ‘0xc969dc0b07ace3e99d6c2636e26d80086a90b847’,
toAddress: ‘0xa193b32dee0f33c80b88e27cefae39b5a8fd3990’,
value: ‘0’,
type: ‘2’,
v: ‘0’,
r: ‘52613429329988332799292808020999707556370032921027628866103740236689491107819’,
s: ‘47351151172851243189971094392156213312637209287201332767865929807870940107053’,
receiptCumulativeGasUsed: ‘65641’,
receiptGasUsed: ‘65641’,
receiptContractAddress: null,
receiptRoot: null,
receiptStatus: ‘1’
}
],
txsInternal: [],
erc20Transfers: [],
erc20Approvals: [],
nftApprovals: { ERC1155: [], ERC721: [] },
nftTransfers: []
}

you can decode this event with that abi, there are various options to decode it, what is web3 decodeData?

you can use something like this