Self-hosting your Moralis server

gotcha, will give it a try.
cheers.

1 Like

After a bit of searchingā€¦ gcp cloud run seems to be a good heroku replacement with a free tier that still lets me be sufficiently lazy. Didnā€™t try Render.com yet though.

1 Like

Hello @cryptokid ,

How do we schedule Jobs in a self-hosted parse server? Is there any guide?

maybe this helps

there is a separate module for scheduling jobs for parse server

you can also use cron jobs directly on your own server

1 Like

Hi, I searched and could not find anywhere the technical requirements for a server to self-host moralis server.

E.g. to run an Avalanche RPC: https://docs.avax.network/nodes/build/set-up-node-with-installer

Requirements for an Avalanche RPC:

  • CPU: Equivalent of 8 AWS vCPU
  • RAM: 16 GiB
  • Storage: 1 TiB
  • OS: Ubuntu 20.04 or MacOS >= 12
  • Network: sustained 5Mbps up/down bandwidth

Somewhere else I see more ā€œhumbleā€ requiremnts: https://gist.github.com/cgcardona/4a5c9d0dbe7fdbe6ffce77fa05e9e580

  • 4 CPUs
  • 8 GB
  • 160 GB SSD Disk
  • 5 TB transfer
    (I donā€™t believe that 160 GB disk are enoughā€¦ Iā€™d calculate at least 300 GB for avalanche)

So I wonder, if I need a moralis server supporting both Avalanche and other chainsā€¦ do I need to calculate for each chain like 500 GB- 1 TB of space depending on the chain, and equivalent RAM?

Or is Moralis smart also for this and is fetching data from a central place and thus doesnā€™t need to validate blocks like a full node does?

So, realistically, i I have a VPS with 1.5TB, CPU: 14 cores, 32 GB RAM, how many chains can this support?

Iā€™d like to support these chains:

  • Avalanche
  • BSC
  • Polygon

The main features I need are:

  • track NFT transfers
  • track various events (both fetch events from the past and real-time)

I was considering to install my own RPC for each chain I need, but moralis makes things easier than using RPCs.

I also was wondering if a Moralis server has an RPC for each chain and if I have access to itā€¦ or how does it work behind the scenes?

Thanks for your answers, especially the technical requirements (my suggestion for you) should be in the documentation: https://docs.moralis.io/docs/v1-server-self-hosting?utm_source=blog&utm_medium=post&utm_campaign=Introducing%20Self-Hosted%20Moralis%20Servers

Cheers

this should be more then enough for you

you will have to use Streams API to sync events and nft transfers, you can use your own custom backend and database if you want too, you donā€™t have to necessarily use parse server unless you want it to work with moralis v1 sdk

Thanks mate, Iā€™m eyeing VPS server on netcup: https://www.netcup.eu/vserver/vps.php#v-server-details

If I could get a lower specs:

  • 12 vCore
  • 24 GB RAM
  • 960 GB SSD (RAID10)

Or:

  • 10 vCore
  • 18 GB RAM
  • 640 GB SSD (RAID10)

How does moralis work behind the scenes? Where does the moralias server fetch the blockchain data if it doensā€™t run a full node behind the scenes?

it does run a full node behind the scenes, but if you want to use the API from moralis then you will get only the info that you need

if you want to run a full node then you will probably need higher specs

1 Like

Do I guess it right that it runs a node behind the scenes but then it ā€œprunesā€ the blocks to save up space and saves the info in mongo DB for easier/less expensive in terms of queirying fetching of data?

So basically what needs a lot of space is the blockchain data, but do you know how much space is needed right now on a moralias server for each chain?

For me the advantage of using a self hosted moralis server, despite being ā€œv1ā€, is to avoid paying for queries. I see the free account has some limits, so if I query my own server like crazy I would not need to pay for itā€¦

Btw, do you know if the serve hosted moralis server is gonna have long time support (LTS) or if it will eventually be deprecated as well?

If you tell me the self hosted server has an incertain destiny, then I guess Iā€™ll study more v2. But if itā€™s being supported, then itā€™s definitively interesting.

you can self host with parse server, current moralis server uses parse server behind the scenes

with parse server it is easy to use cloud code and it uses by default mongo db, but you can use any other backend or programming language or technology if you want

you will need a way to get the data on the server in the first place, that can be done with web3api, with streams API or with another method that you find

we plan to provide support for web3api and streams API in the future for a long time

1 Like

We currently have a lot of things in Cloud Functions. What is the quickiest way to migrate the cloud functions code to self-hosted cloud functions server?

For example,

Moralis.web3ByChain does not exist
Moralis.Cloud does not exist
many other errors from typescript

Moralis.Cloud can be replaced with Parse.Cloud

Moralis.web3ByChain doesnā€™t work now either, you can import directly ethers or web3 in cloud code

1 Like

Hi everyone,

I actually followed the tutorial step-by-step and deployed on Heroku, but the server url is returning an error as shown in the image below as well as the build log.

-----> Building on the Heroku-22 stack
-----> Determining which buildpack to use for this app
-----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       USE_YARN_CACHE=true
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       engines.yarn (package.json):  unspecified (use default)
       
       Resolving node version 18.x...
       Downloading and installing node 18.11.0...
       Using default npm version: 8.19.2
       Resolving yarn version 1.22.x...
       Downloading and installing yarn (1.22.19)
       Installed yarn 1.22.19
       
-----> Installing dependencies
       Installing node modules (yarn.lock)
       yarn install v1.22.19
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       warning Pattern ["debug@>= 2.6.9 < 3.0.0 || >= ^3.1.0"] is trying to unpack in the same destination "/tmp/yarncache.zNC7V/v6/npm-debug-3.2.7-72580b7e9145fb39b6676f9c5e5fb100b934179a-integrity/node_modules/debug" as pattern ["debug@^3.1.0","debug@^3.2.7","debug@^3.2.7"]. This could result in non-deterministic behavior, skipping.
       [3/4] Linking dependencies...
       [4/4] Building fresh packages...
       Done in 28.82s.
       
-----> Build
       Running build (yarn)
       yarn run v1.22.19
       $ tsc
       Done in 2.92s.
       
-----> Pruning devDependencies
       yarn install v1.22.19
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       warning Pattern ["debug@>= 2.6.9 < 3.0.0 || >= ^3.1.0"] is trying to unpack in the same destination "/tmp/yarncache.zNC7V/v6/npm-debug-3.2.7-72580b7e9145fb39b6676f9c5e5fb100b934179a-integrity/node_modules/debug" as pattern ["debug@^3.1.0","debug@^3.2.7","debug@^3.2.7"]. This could result in non-deterministic behavior, skipping.
       [3/4] Linking dependencies...
       [4/4] Building fresh packages...
       warning Ignored scripts due to flag.
       Done in 3.57s.
       
-----> Caching build
       - yarn cache
       
-----> Build succeeded!
-----> Discovering process types
       Procfile declares types     -> (none)
       Default types for buildpack -> web
-----> Compressing...
       Done: 70.9M
-----> Launching...
       Released v3
       https://myparseserver.herokuapp.com/ deployed to Heroku


Any form of pointer to what the issue is would be greatly appreciated.

Thank you

Could you provide an example?

did you set the environment variables?

you can use ethers as you use it directly in nodejs, when you self host you can import any external library in cloud code

Yes, I did that, and I have as well restarted the server (dyno), yet it still throws the same error

it is expected to use node 18?

and how about solving the ā€œanyā€ type returned by Web3API? . For example, this line

var NFTs = await Parse.Web3API.account.getNFTs(options);

when we try to access the object, like

NFTs.result[i].token_id

the build says

I donā€™t know this part, you can use directly Moralis v2 sdk in cloud code if you want

you are calling this in cloud?