Moralis function list

Hi! I’m looking for the complete list of call-able useMoralis() functions. I’m working in react-moralis so I’ve gone through the code on GitHub and dug up:

Moralis: Moralis;

  isInitialized: boolean;

  authenticate: (options?: AuthenticateOptions) => Promise<void>;
  logout: () => Promise<void>;
  signup: Signup;
  login: Login;

  auth: Authentication;
  authError: Error | null;
  isAuthenticated: boolean;
  isUnauthenticated: boolean;
  isAuthenticating: boolean;
  hasAuthError: boolean;
  isLoggingOut: boolean;
  isAuthUndefined: boolean;

  setUserData: (data: SetUserData) => Promise<void>;
  user: Moralis.User | null;
  userError: null | Error;
  isUserUpdating: boolean;

  enableWeb3: () => void;
  web3: Moralis.Web3 | null;
  isWeb3Enabled: boolean;
  web3EnableError: Error | null;
  isWeb3EnableLoading: boolean;

Which is a good start and I’ve all my log-in/authenticate functions working. But there’s a TON of cloud functions missing. I can’t find a list or reference to things like what should be here, but are missing.

I’ve been searching for days and can’t find just a simple example of how to get the current user’s eth balance with useMoralis()…that actually works. I know it’s possible because I’m surrounded by a circus of working Moralis aps people are asking far more advanced questions about.

I just need to see an example of a working (ReactJS) component structure and a current list of available default cloud functions and I’ll be on my way. I can’t seem get off the ground without it.

Can somebody help?

All build–in functions of react-moralis are documented in the GitHub repo README. or like you have discovered, you can check the Typescript definitions.

As of now, react-moralis only has the most-used functionalities build in. We will expand on this more.

But you still have access to all Moralis functionalities within React. You just need to write a bit more logic or make your own custom hook.

For example, to get the user balance:

  const { authenticate, logout, isAuthenticated, Moralis } = useMoralis();

  useEffect(() => {
  }, [isAuthenticated, Moralis]);

  return (
      {!isAuthenticated && <button onClick={() => authenticate()}>Login</button>}
      {isAuthenticated && <button onClick={() => logout()}>Logout</button>}
1 Like

@Erno thank you kindly sir. In the end that was a ReactJS question about async and the piece I was missing was .then(). I’m still need Moralis.Web3.utils.fromWei() to work but I suspect that’s a capitalization issue I can work out inspecting objects in console.

import { Text } from "@chakra-ui/react";
import { useMoralis } from "react-moralis";
import { useEffect, useState } from "react";

export const Balance = () => {
  const { isAuthenticated, Moralis } = useMoralis();
  const [balance, setBalance] = useState(-1);

  useEffect(() => {
    if (isAuthenticated) {
      Moralis.Web3.getERC20().then((balanceObject) => {
  }, [isAuthenticated, Moralis, setBalance]);

  return <Text>Balance: {balance} Wei</Text>;


You shouldn’t use set functions as a dependency. Use a variable instead

useEffect(() => {
  }, [isAuthenticated, Moralis, *balance*]);

For use the functions fromWei and ToWei in React you just need:

const { web3 } = useMoralis();

console.log(web3.utils.fromWei('amount', 'ether'));
1 Like

Thank you. I’m still learning React. I get useEffect now, just want it to fire on dependency change and the linter is an idiot.

Ah. fromWei() takes strings. I think I was sending amount in as a number. I’ll try that.

1 Like

Hello. To improve speed of code you always should pass numbers as strings.