Moralis Admin CLI

Initial setup

To use the Moralis Admin CLI you need to install it by running the following code in the terminal:

npm install -g moralis-admin-cli

To see the complete list of available commands run the help command:

moralis-admin-cli help

To get further information about a command append helpto the command:

moralis-admin-cli watch-cloud-file help

Arguments to the commands

You can specify the arguments for each command in a combination of three ways:

1. Inline arguments

You can specify the arguments inline by either the short or long flag:

moralis-admin-cli watch-cloud-file --moralisApiKey 4fj5edfj553jdj5jfd
# Or
moralis-admin-cli watch-cloud-file -k 4fj5edfj553jdj5jfd

2. Use an .env file

You can place most arguments in a .env file:

moralisApiKey=4fj5edfj553jdj5jfd
moralisApiSecret=5jd7kg3kd9d93jfljkb
...

By doing this you don't need to specify the arguments inline as long as the .env file is located in the directory that you are running the command from.

3. Use environment variables

You can also store the arguments as environment variables on your local machine.

To do this on a Windows machine, press the Windows Key and type "environment variables".

Select "Edit the system environment variables":

Select "Environment Variables"

Select: "New"

Input the name and value for the variable and press OK

Repeat for each variable that you want to store.

watch-cloud-file

You can write your cloud functions in your preferred IDE by making use of the moralis-admin-cli.

Head to the admin panel and open up the cloud functions on the server you want to work on.

In the lower part of the modal there will be a code snippet that you need to run in the terminal.

The only thing you need to change is the path to the local Javascript file on your computer that contains the cloud functions.

After you have run the command the cloud code will be updated automatically on the backend with each save!

connect-local-devchain

In order to use this command you need to have frpc on you computer. You can get it here: https://github.com/fatedier/frp/releases

You can now run the following command to start the process (Insert your own key, secret and path):

moralis-admin-cli connect-local-devchain --moralisApiKey FAM6pYzBKjcM
--moralisApiSecret 7thQGNKKqX8s --frpcPath "C:\Program Files\frpc\frpc.exe"

To get more information you can write:

moralis-admin-cli connect-local-devchain help

This will show you a more detailed description about the command as well as show you how you can call the command without needing to specify the arguments each time.

You can leave out the arguments if you follow option 2 or 3 in the Initial setup section.

update-server

You can update and restart your Moralis servers from the command line by using the update-servercommand.

You can now run the following command to start the process (Insert your own key, secret and path):

moralis-admin-cli update-server --moralisApiKey FAM6pYzBKjcM
--moralisApiSecret 7thQGNKKqX8s

To get more information you can write:

moralis-admin-cli update-server help

This will show you a more detailed description about the command as well as show you how you can call the command without needing to specify the arguments each time.

You can leave out the arguments if you follow option 2 or 3 in the Initial setup section.

create-server

You can create new Moralis servers from the command line by using the create-servercommand.

Run the following command to start the process (Insert your own key, secret and path):

moralis-admin-cli create-server --moralisApiKey FAM6pYzBKjcM
--moralisApiSecret 7thQGNKKqX8s

To get more information you can write:

moralis-admin-cli create-server help

This will show you a more detailed description about the command as well as show you how you can call the command without needing to specify the arguments each time.

You can leave out the arguments if you follow option 2 or 3 in the Initial setup section.

add-contract

You can choose to listen and sync smart contract events to your Moralis servers from the command line by using the add-contractcommand.‌

Run the following command to start the process (Insert your own key, secret and path):exit: Ctrl+↩

moralis-admin-cli add-contract --moralisApiKey FAM6pYzBKjcM
--moralisApiSecret 7thQGNKKqX8s --abiPath ".\MyContract.json"

To get more information you can write:

moralis-admin-cli add-contract help

‌This will show you a more detailed description about the command as well as show you how you can call the command without needing to specify the arguments each time.‌

You can leave out the arguments if you follow option 2 or 3 in the Initial setup section.

deploy

You can deploy your dApp to be hosted on Moralis using the deploy command.

The only two required parameters are moralisApiKey and moralisApiSecret.

The command will default to deploying the contents of the folder from where the command is executed.

If you want to specify another folder, you can do that by using the --folderPath or -p flags.

Example:

moralis-admin-cli deploy --p C:\myDapp\

You can also choose to specify the server to deploy to by using the --moralisSubdomain or -d flags.

Example:

moralis-admin-cli deploy --d dajbrubkfnoi.moralis.io

If if the --moralisSubdomain or -d flags are left out you will get to choose from a list of your servers.

To get more information you can write:

moralis-admin-cli deploy help

This will show you a more detailed description about the command as well as show you how you can call the command without needing to specify the arguments each time.

You can leave out the arguments if you follow option 2 or 3 in the Initial setup section.

undeploy

You can remove your deployed dApp from a Moralis server by using the undeploy command.

The only two required parameters are moralisApiKey and moralisApiSecret.

You can choose to specify the server to undeploy to by using the --moralisSubdomain or -d flags.

Example:

moralis-admin-cli undeploy --d dajbrubkfnoi.moralis.io

If if the --moralisSubdomain or -d flags are left out you will get to choose from a list of your servers.

To get more information you can write:

moralis-admin-cli undeploy help

This will show you a more detailed description about the command as well as show you how you can call the command without needing to specify the arguments each time.

You can leave out the arguments if you follow option 2 or 3 in the Initial setup section.