How to connect to and query self hosted moralis server via hardhat?

Hey guys,

How do we connect to the self hosted moralis server (on hardhat)? I need to do this to test cloud code. I used to use the following command to test on Moralis hosted server:

moralis-admin-cli connect-local-devchain --chain hardhat --moralisSubdomain mgjfj1lq8sbh.usemoralis.com --frpcPath ./frp/frpc

I tried doing this now, replacing Moralis subdomain with my localhost domain, however that gives an frpc error.

Also, from the client file, what syntax do we use to query the database. Do we continue using Moralis.Cloud?

Local devchain or hardhat doesn’t work now with a self hosted server unless you handle somehow that functionality. You can change the cloud code for your self hosted server but it will not know how to query the local devchain by default.

There is a specific file for cloud code that you can change for you local hosted server in case that you used parse server. It is names cloud.js

Yep. I believe it’s named main.js in the Cloud folder. Also, from the front end we still use Moralis.Query to query the database, right (on parse server)?

Yes, if you use Moralis v1 sdk then it should work like that in front end. You can also use parse server sdk directly

1 Like

then how to connect to hardhat in it , can you explain the procedure more concisely?

Hi @Debasis Please open a new post with your question and error details. Since this post has some depreciated content I will close this one.