⚠ 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.
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 functionalites via, as described in our extensive docs
If this JS SDK helps you build your dapps faster - please star this project, 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.
- 🚨 Beta version
- 🚀 Quick start
- ⭐️ Star us
- 🤝 Need help
- 🧭 Table of Contents
- ⚙️ Configuration
- 👩🔬 Advanced setup
- 📦 Packages
- 🧙♂️ Community
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 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();
package | Changelog | Description |
---|---|---|
moralis | CHANGELOG.md | Umbrella package that includes all packages and initialises 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 |