Socket
Socket
Sign inDemoInstall

moralis

Package Overview
Dependencies
Maintainers
7
Versions
342
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moralis

Moralis SDK for JavaScript and TypeScript


Version published
Weekly downloads
26K
decreased by-2.87%
Maintainers
7
Weekly downloads
 
Created
Source
Moralis JS SDK

Moralis SDK (JavaScript / TypeScript)

Join the Moralis DAO on Discord Check the docs Discourse posts
npm

A library that gives you access to the powerful Moralis Server backend from your JavaScript app.



⚠ WARNING: This library is dedicated to back-end projects only. You should NOT use this library for a front-end project. Keep your API key secret and don't disclose it.

Features:

  • Web3 authentication
  • Make Evm api and Solana api calls
  • Consistent data types and utilities
  • Modular package: include only what you need
  • Fully Typescript ready out-of-the box

... and much more. Check out the official Moralis docs for more details.

🚀 Quick start

If you're new to Moralis, check the quickstart guide in the official docs on how to get started.

If you're already familiar with Moralis and have your server set up. Then follow along to connect your SDK:

1. Install Moralis

The easiest way to integrate the Moralis SDK into your JavaScript project is through the npm module.

Install the package via npm:

npm install moralis

or yarn:

yarn add moralis

Import Moralis:

import Moralis from 'moralis';

2. Initialize Moralis

After your dependency is added, you simply need to initialize moralis via the start method:

Moralis.start({
  apiKey: 'YOUR_API_KEY',
});

After that you can use any Moralis functionalities as described in our extensive docs

⭐️ Star us

If this JS SDK helps you build your dapps faster - please star this project on Github, every star makes us very happy!

🤝 Need help

If you need help with setting up the boilerplate or have other questions - don't hesitate to write in our community forum and we will check asap. Forum link. The best thing about this SDK is the super active community ready to help at any time! We help each other.

🧭 Table of Contents

⚙️ Configuration

When calling Moralis.start, you can include a configuration object.

👩‍🔬 Advanced setup

It's possible to install all functionalities of Moralis by installing moralis as a dependency. But, you may choose to only install certain modules (as listed below).

1. Install the dependencies

Instead of installing moralis you can need to install the packages that you want to use. You always need to install the @moralisweb3/core package. For example:

yarn add @moralisweb3/core @moralisweb3/evm @moralisweb3/evm-api @moralisweb3/evm-wallet-connect-connector

Then at the top of your code (before any interaction with Moralis), you need to register the modules to the core package

import MoralisCore from '@moralisweb3/core';
import MoralisEvmApi from '@moralisweb3/evm-api';

const core = MoralisCore.create();
// Register all imported modules to the @moralisweb3/core module
core.registerModules([MoralisEvmApi]);

Then, initialize the app the same way as when using the umbrella moralis package. You only need to provide configuration that is required by the packages. So if you don't include an api package, then you might not need to include the apiKey.

core.start({
  apiKey: 'YOUR_API_KEY',
  // ...and any other configuration
});

Now you can use any functionality from the installed modules. The only difference is that you need to call in your code:

import MoralisEvmApi from '@moralisweb3/evm-api';

const evmApi = core.getModule<MoralisEvmApi>(MoralisEvmApi.moduleName);
evmApi.block.getBlock();

Instead of

import Moralis from 'moralis';

Moralis.EvmApi.block.getBlock();

Of course you are free to combine the modules in a single object, and use that in your dapp.

// moralis.ts
import { MoralisCore } from '@moralisweb3/core';
import EvmApi from '@moralisweb3/evm-api';

const core = MoralisCore.create();
const evmApi = EvmApi.create(core);
core.registerModules([evmApi]);

export const Moralis = {
  EvmApi: evmApi,
};

// app.ts
import { Moralis } from './moralis/';

Moralis.EvmApi.block.getBlock();

📦 Packages

Umbrella package

packageChangelogDescription
moralisCHANGELOG.mdUmbrella package that includes all packages and initializes them

Core module

The core module is required in all applications. It will handle global dependencies and communications between other packages.

packageChangelogDescription
@moralisweb3/coreCHANGELOG.mdCore logic, responsible for core logic and sharing state and events between packages

Utilities

packageChangelogDescription
@moralisweb3/evm-utilsCHANGELOG.mdUtility functions and datatypes for EVM chains.
@moralisweb3/sol-utilsCHANGELOG.mdUtility functions and datatypes for Solana networks.
@moralisweb3/api-utilsCHANGELOG.mdGeneric functions, used in all api logic within the SDK.

Moralis functionalities

packageChangelogDescription
@moralisweb3/evm-apiCHANGELOG.mdFetch data from an EVM chain
@moralisweb3/sol-apiCHANGELOG.mdFetch data from a Solana network
@moralisweb3/authCHANGELOG.mdHandle authentication

Other

packageChangelogDescription
@moralisweb3/eslint-config-Eslint configuration that is used within Moralis

🧙‍♂️ Community

Keywords

FAQs

Package last updated on 16 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc