Sending HTTP POST requests on database changes

Hi,

I am trying to use the Moralis API as an authentication method for NFT gated access to a Web 2.0 website. I followed the authentication tutorial in the docs but I’m a bit confused about what Moralis really is supposed to be used for so let me explain what I want to do and maybe somebody can point me in the right direction.

  1. Validate the signature of a metamask user to verify their ownership of an NFT from a specific contract (done with authentication tutorial in the docs).
  2. Receive POST updates to my Web 2.0 server for every sale of a user’s NFT (I have no idea how to do this)
  3. Receive POST updates to my Web 2.0 server for any sale of a specific NFT contract. (I have no idea how to do this)

As I said I’m a bit confused about what Moralis is really used for. It seems to be a platform for building out an application that lives on Web 3.0, so is it even reasonable to try and use it for my use case?

Moralis is an infrastructure provider so it can provide the backend, database, API for on-chain data, etc. for Web3 apps. You can see this to learn why people use Moralis.

  1. Validate the signature of a metamask user to verify their ownership of an NFT from a specific contract (done with authentication tutorial in the docs).

This is to authenticate users and save them into your Moralis server.

If you wanted to verify NFT ownership, you could just call ownerOf on your contract to compare the address with the current logged in user. Or alternatively use the API to get ownership e.g. with getTokenIdOwners.

  1. Receive POST updates to my Web 2.0 server for every sale of a user’s NFT (I have no idea how to do this)
  1. Receive POST updates to my Web 2.0 server for any sale of a specific NFT contract. (I have no idea how to do this)

It depends how this is handled. But if sales emitted a contract event with useful data, you could sync the events to your Moralis server and then use the data appropriately. For 2, you could just filter out these events based on the user’s address.

1 Like

Is it possible to run ownerOf in a cloud.js function?

Yes, ownerOf (which is a contract read call) can be done in a Cloud Function.