Code Monkey home page Code Monkey logo

testalis'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.


Features:

  • Connect to EVM via MetaMask, WalletConnect, MagicLink and many more connectors (or create your own connetor)
  • Connect to Moralis via other networks as Solana, Polkadot, Elrond and more
  • Authenticate to Moralis via connection methods specified above
  • Evm Utilities for transfers, contract interactions and other on-chain methods for the supported networks (and support for other networks as Solana, Polkadot, Elrond and more)
  • Interaction with the Moralis server like: database queries, handling user sessions, calling cloud-functions etc.
  • Make Evm api and Solana api calls
  • 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

Package manager

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

Browser (UMD)

If you want to use a pre-compiled file from unpkg:

TODO

Browser (ESM)

Or if you prefer the more modern EsModule build:

TODO

2. Initialise Moralis

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

import { Moralis } from 'moralis';

Moralis.start({
  serverUrl: '<YOUR_SERVER_URL>',
  appId: '<YOUR_APP_ID>',
});

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.

๐Ÿฅท Support for NodeJs (backend) server

TODO

โš›๏ธ Support for react-native

TODO

๐Ÿ‘ฉโ€๐Ÿ”ฌ 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 @ernotestalis/core package. For example:

yarn add @ernotestalis/core @ernotestalis/evm @ernotestalis/evm-api @ernotestalis/evm-walletconnect-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 '@ernotestalis/core';
import Server from '@ernotestalis/server';
import EvmApi from '@ernotestalis/evm-api';
import Evm from '@ernotestalis/evm';
import WalletConnectConnector from '@ernotestalis/evm-walletconnect-connector';

// Register all imported modules to the @ernotestalis/core module
MoralisCore.registerModules({
  // Add any network modules
  networks: [Evm],
  // Add any api modules
  networks: [EvmApi],
  // Add any other modules
  modules: [Server],
});

// Add any additional connectors for the Evm network
Evm.wallet.register(WalletConnectConnector);

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 the server package, then you might not need to include the serverUrl and appId.

MoralisCore.start({
  serverUrl: '<YOUR_SERVER_URL>',
  appId: '<YOUR_APP_ID>',
  // ...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 Evm from '@ernotestalis/evm';

Evm.connect();

Instead of

import Moralis from 'moralis';

Moralis.Evm.connect();

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

// moralis.ts
import Evm from '@ernotestalis/evm';
import Server from '@ernotestalis/server';

export const Moralis = {
  Evm,
  Server,
};

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

Moralis.Evm.connect();

๐Ÿ“ฆ Packages

Umbrella package

package Version Changelog Description
moralis TODO TODO 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 Version Changelog Description
@ernotestalis/core TODO TODO Core logic, responsible for core logic and sharing state and events between packages

Main modules

package Version Changelog Description
@ernotestalis/server TODO TODO Connecting and interaction with your moralis server instance server
@ernotestalis/plugins TODO TODO

API modules

These are packages that wrap around the Moralis apis for easy use. You can call to any endpoint with a single function call. These modules will also wrap the returned data in Moralis datatypes, to ensure consistent data accross all modules.

package Version Changelog Description
@ernotestalis/evm-api TODO TODO
@ernotestalis/sol-api TODO TODO

Network modules

package Version Changelog Description
@ernotestalis/evm TODO TODO All logic regarding connecting to EVM networks
@ernotestalis/sol TODO TODO All logic regarding connecting to Solana networks

Connectors

Connectors are modules that allow access to on-chain activities. These are required to establish a connection with any network package.

package Version Changelog Description
@ernotestalis/evm-connector-utils TODO TODO Utilities for EVM connectors
@ernotestalis/evm-metamask-connector TODO TODO Connector to connect to an EVM network via Metamask
@ernotestalis/evm-wallet-connect-connector TODO TODO Connector to connect to an EVM network via Walletconnect
@ernotestalis/sol-phantom TODO TODO TODO

Other

package Version Changelog Description
TODO TODO

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

testalis's People

Contributors

ernow avatar

Watchers

 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.