โ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