Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
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:
... and much more. Check out the official Moralis docs for more details.
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:
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';
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
If this JS SDK helps you build your dapps faster - please star this project on Github, every star makes us very happy!
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.
When calling Moralis.start
, you can include a configuration object.
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).
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();
package | Changelog | Description |
---|---|---|
moralis | CHANGELOG.md | Umbrella package that includes all packages and initializes them |
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 |
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. |
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 |
package | Changelog | Description |
---|---|---|
@moralisweb3/eslint-config | - | Eslint configuration that is used within Moralis |
FAQs
Moralis SDK for JavaScript and TypeScript
The npm package moralis receives a total of 21,700 weekly downloads. As such, moralis popularity was classified as popular.
We found that moralis demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.