Giter Site home page Giter Site logo

moralis-js-sdk's Introduction

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 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. Initialise 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 functionalites via, as described in our extensive docs

โญ๏ธ Star us

If this JS SDK helps you build your dapps faster - please star this project, 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 configation 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

package Changelog Description
moralis CHANGELOG.md Umbrella package that includes all packages and initialises them

Core module

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

package Changelog Description
@moralisweb3/core CHANGELOG.md Core logic, responsible for core logic and sharing state and events between packages

Utilities

package Changelog Description
@moralisweb3/evm-utils CHANGELOG.md Utility functions and datatypes for EVM chains.
@moralisweb3/sol-utils CHANGELOG.md Utility functions and datatypes for Solana networks.
@moralisweb3/api-utils CHANGELOG.md Generic functions, used in all api logic within the SDK.

Moralis functionalities

package Changelog Description
@moralisweb3/evm-api CHANGELOG.md Fetch data from an EVM chain
@moralisweb3/sol-api CHANGELOG.md Fetch data from a Solana network
@moralisweb3/auth CHANGELOG.md Handle authentication

Other

package Changelog Description
@moralisweb3/eslint-config - Eslint configuration that is used within Moralis

๐Ÿง™โ€โ™‚๏ธ Community

moralis-js-sdk's People

Contributors

3scava1i3r avatar adamrhunter avatar ayorcodes avatar b4rtaz avatar capplequoppe avatar dani69654 avatar dependabot[bot] avatar ernow avatar gerardo15 avatar github-actions[bot] avatar golden-c avatar ivan-liljeqvist avatar javier123454321 avatar jeffpdotone avatar kantorcodes avatar meseta avatar microhoffman avatar mobilekosmos avatar rayyan224 avatar rphansen91 avatar semantic-release-bot avatar sey avatar sogunshola avatar y0moo avatar yosephks avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.