β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?
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