Using moralis serverside

Hi, I want to communicate and write data with my smart contract via a cronjob driven script. Normally I would do something like this with PHP or Python. Probably node.js is a good choice? Then I can use moralis on the server side? But I need at least a little gas. Presumably I have to install an Ethereum node on the same server?

Hi JackBlue,

Yes, the Moralis SDK can also be used in a Node app. See the docs here as the import is slightly different:
https://docs.moralis.io/#nodejs

Be sure to initialize the Moralis server url and app id. Once you have a Moralis instance you can use it in the same as in the browser- i.e. authenticate, run cloud functions, etc.

Currently calling Moralis.Web3.enable() relies on window.ethereum which is only available in the browser, not in node. This means you’ll also need to install either the Web3.js or Ethers package to interact with your contract and sign transactions. See their docs for installation and usage.

Hope that helps.

1 Like

Thanks a lot! And habe a nice day!