Moralis Webhook Verify Signatures

Currently, Iโ€™m using an EVM stream to monitor events from a given contract. My backend is receiving those events and itโ€™s written in Ruby. I would like to verify that the data that comes to the webhook url comes from Moralis. I checked this link and I would like to know if it possible to have something like that but using Ruby instead of JS.

Thanks in advance

you can implement the equivalent of that check in ruby, it just checks the signature

const verifySignature = (req, secret) => {

    const ProvidedSignature = req.headers["x-signature"]
    if(!ProvidedSignature) throw new Error("Signature not provided")
    const GeneratedSignature= web3.utils.sha3(JSON.stringify(req.body)+secret)
    if(GeneratedSignature !== ProvidedSignature) throw new Error("Invalid Signature")

}
1 Like