Skip to content

Commit

Permalink
Refactor V2
Browse files Browse the repository at this point in the history
Edit the images
Added missing {target=\_blank} elements for URLs
refactors wording
  • Loading branch information
wuzhong-papermoon committed Jul 24, 2024
1 parent be93301 commit f095b32
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 50 deletions.
2 changes: 1 addition & 1 deletion builders/integrations/indexers/.pages
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ nav:
- index.md
- 'The Graph': 'thegraph.md'
- 'Covalent API': 'covalent.md'
- 'Moralis': moralis.md
- 'Moralis': 'moralis.md'
- 'SubQuery': 'subquery.md'
- 'Subsquid': 'subsquid.md'
103 changes: 54 additions & 49 deletions builders/integrations/indexers/moralis.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
---
title: Moralis
description: Learn how to build on the Moonbeam network with Moralis' API suite.
title: Interact with Moralis APIs
description: Learn how Moralis' API suite empowers developers to retrieve and leverage various data sets from Moonbeam, Moonriver, and Moonbase.
---

# Index Moonbeam with Moralis
# Access Moonbeam data via Moralis APIs

## Introduction {: #introduction }

As a one-stop solution for blockchain development, [Moralis](https://moralis.io/) offers a comprehensive platform that empowers developers to create, launch, and scale decentralized applications (dApps) with ease. This guide will show you how to access the API endpoints for Moonbeam using curl commands and JavaScript and Python snippets.
As a one-stop solution for blockchain development, [Moralis](https://moralis.io/){target=\_blank} offers a comprehensive platform that empowers developers to create, launch, and scale decentralized applications (dApps) with ease.

Moralis' offerings are structured into four primary categories of API services:

- **EVM API**: EVM API allows developers to query essential data for Ethereum Virtual Machine (EVM)-compatible blockchains. Moralis provides dedicated APIs for four key areas: NFTs, tokens, wallets, and general blockchain information.
- **EVM API** - EVM API allows developers to query essential data for Ethereum Virtual Machine (EVM)-compatible blockchains. Moralis provides dedicated APIs for four key areas: NFTs, tokens, wallets, and general blockchain information

- **Streams API**: The Streams API enables developers to listen for on-chain events, such as smart contract event emissions, in real-time. Popular use cases include real-time wallet notifications, asset monitoring, and gaming event notifications.
- **Streams API** - the Streams API enables developers to listen for on-chain events, such as smart contract event emissions, in real-time. Popular use cases include real-time wallet notifications, asset monitoring, and gaming event notifications

- **RPC API**: The RPC API offers a secure and reliable connection to various blockchain networks. It provides a high-performance gateway for developers to interact with blockchain nodes, ensuring stable and efficient communication between dApps and the blockchain.
- **RPC API** - the RPC API offers a secure and reliable connection to various blockchain networks. It provides a high-performance gateway for developers to interact with blockchain nodes, ensuring stable and efficient communication between dApps and the blockchain

- **Auth API**: Moralis's Auth API offers a secure method for implementing wallet-based authentication in dApps. This service simplifies the often complex process of verifying user identities and managing sessions in a decentralized context.
This guide will show you how to access the API endpoints for Moonbeam using curl commands and the Moralis SDK using JavaScript and Python snippets.

--8<-- 'text/_disclaimers/third-party-content-intro.md'

## Checking prerequisites {: #checking-prerequisites }
## Checking Prerequisites {: #checking-prerequisites }

To access the endpoint, a Moralis account and API key are required.
To interact with Moralis' API endpoints, an account and API key are required

Head over to the [signup page](https://admin.moralis.io/register) to create an account. Once you're in, navigate to the API keys section. There, you can generate your own unique API key and be sure to copy it for future use.
Head to the [sign up page](https://admin.moralis.io/register){target=\_blank} to create an account. Once you're in, navigate to the **API keys** section. There, you can generate your own unique API key. Be sure to copy it for future use.

![Moralis API key](/images/builders/integrations/indexers/moralis/moralis-1.webp)

## Querying Moralis API {: #querying-moralis-api }
## Querying the EVM API {: #querying-the-evm-api }

With the API key, you can try Moralis' REST APIs. The following examples show how the EVM API works:

Get the token balance of a wallet:

```bash
curl --request GET \
--url 'https://deep-index.moralis.io/api/v2.2/0xd4d7fb1f98dD66f6D1f393E8e237AdF74c31F3ea/erc20?chain=moonbeam' \
--header 'accept: application/json' \
--header 'X-API-Key: INSERT_YOUR_API_KEY'
--url 'https://deep-index.moralis.io/api/v2.2/0xd4d7fb1f98dD66f6D1f393E8e237AdF74c31F3ea/erc20?chain=moonbeam' \
--header 'accept: application/json' \
--header 'X-API-Key: INSERT_YOUR_API_KEY'
```

Get the list of owners of an NFT:

```bash
curl --request GET \
--url 'https://deep-index.moralis.io/api/v2.2/nft/0xfffffffffffffffffffffffffffffffffffffffff/owners?chain=moonbeam&format=decimal' \
--header 'accept: application/json' \
--header 'X-API-Key: INSERT_YOUR_API_KEY'
--url 'https://deep-index.moralis.io/api/v2.2/nft/0xfffffffffffffffffffffffffffffffffffffffff/owners?chain=moonbeam&format=decimal' \
--header 'accept: application/json' \
--header 'X-API-Key: INSERT_YOUR_API_KEY'
```

For a comprehensive overview of the available APIs and their capabilities, please refer to Moralis' [official documentation](https://docs.moralis.io/web3-data-api/evm/reference).
For a comprehensive overview of EVM APIs and their capabilities, please refer to Moralis' [official documentation](https://docs.moralis.io/web3-data-api/evm/reference){target=\_blank}.

## Moralis SDK {: #moralis-SDK }
## Using the Moralis SDK {: #using-the-moralis-SDK }

Moralis has an SDK that allows developers to seamlessly integrate Moralis' API into their backend infrastructure. This SDK offers a wide array of features, including:

- Data querying from both EVM and Solana APIs
- Data querying from EVM APIs
- Integration of Web3 authentication
- A collection of utility functions for efficient data transformation and formatting

Expand Down Expand Up @@ -92,26 +92,26 @@ To install Moralis SDK:
pip install moralis
```

Once the SDK is ready, you can leverage it to query Moralis APIs. Here's an example of how to interact with the EVM API using a JSON RPC interface:
Once the SDK is ready, you can leverage it to query Moralis APIs. Here's an example of how to interact with the EVM API using a JSON-RPC interface:

=== "Javascript"

```js
import Moralis from 'moralis';
import Moralis from "moralis";

try {
await Moralis.start({
apiKey: "INSERT_YOUR_API_KEY"
try {
await Moralis.start({
apiKey: "INSERT_YOUR_API_KEY",
});

const response = await Moralis.EvmApi.block.getBlock({
"chain": "0x504",
"blockNumberOrHash": "1"
const response = await Moralis.EvmApi.block.getBlock({
chain: "0x504",
blockNumberOrHash: "1",
});

console.log(response.raw);
console.log(response.raw);
} catch (e) {
console.error(e);
console.error(e);
}
```

Expand All @@ -122,35 +122,33 @@ Once the SDK is ready, you can leverage it to query Moralis APIs. Here's an exam

api_key = "INSERT_YOUR_API_KEY"

params = {
"chain": "moonbeam",
"block_number_or_hash": "1"
}
params = {"chain": "moonbeam", "block_number_or_hash": "1"}

result = evm_api.block.get_block(
api_key=api_key,
params=params,
api_key=api_key,
params=params,
)

print(result)
print(result)
```

For more information on advanced features and configurations within Moralis SDK, please refer to the official documentation:[Javascript](https://moralisweb3.github.io/Moralis-JS-SDK/Introduction){target=\_blank},[Python](https://moralisweb3.github.io/Moralis-Python-SDK/){target=\_blank}.

## Stream API {: #stream-api }
## Accessing Stream API {: #accessing-stream-api }

Moralis Streams API is a tool for developers to listen to and react to events happening on blockchains in real time. This API lets you listen for specific events, such as a new transaction being added to a block, a particular smart contract function being called, or an NFT being transferred and delivering the event via Webhook.
The Moralis Streams API is a tool for developers to listen to and react to events happening on blockchains in real time. This API lets you listen for specific events, such as a new transaction being added to a block, a particular smart contract function being called, or an NFT being transferred and delivering the event via Webhook.

Head over to the Streams page within Moralis and click **Create a new stream** to get started.
Head over to the **Streams** page from your Moralis dashboard and click **Create a new stream** to get started.

![stream API page](/images/builders/integrations/indexers/moralis/moralis-2.webp)

To get started quickly, let's choose a predefined template here. In this example, we're interested in xcDOT transactions. Select the "Contract Activity" template. This will allow us to easily listen for events related specifically to xcDOT.
To get started quickly, choose a predefined template here. This example focuses on transactions related to xcDot. Select the **Contract Activity** template. to listen for events related specifically to xcDOT easily.

![template selection page](/images/builders/integrations/indexers/moralis/moralis-3.webp)

On the next page, enter the following details:

- Smart Contract Address for [xcDot](https://moonscan.io/token/0xffffffff1fcacbd218edc0eba20fc2308c778080): 0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080
- Smart Contract Address for [xcDot](https://moonscan.io/token/0xffffffff1fcacbd218edc0eba20fc2308c778080){target=\_blank}: 0xFfFFfFff1FcaCBd218EDc0EbA20Fc2308C778080
- Network: Select Moonbeam from the available options.
Moralis supports listening to events on Moonbeam, Moonriver, and Moonbase Alpha.

Expand All @@ -166,17 +164,24 @@ Next, you can connect the stream to an endpoint to receive updates from Moralis.

![webhook setup page](/images/builders/integrations/indexers/moralis/moralis-6.webp)

All set. Once you activate your stream, you'll see a screen like this:
All set. Once you activate your stream, it will be added to your list of streams on your dashboard:

![stream API end page](/images/builders/integrations/indexers/moralis/moralis-7.webp)

## RPC API {: #rpc-api }
## Accessing RPC API {: #accessing-rpc-api }

To use the Moralis Moonbeam RPC endpoint, visit the **Nodes** page, click Create Node, and take the following steps:

Moralis also offers node services for Moonbeam networks. To use the Moralis Moonbeam RPC endpoint, visit the Nodes page.
Select **Moonbeam** and **Mainnet** here to get started. Remember, Moralis also supports Moonriver and Moonbase Alpha.
1. Select **Moonbeam** as the protocol
2. Choose **Mainnet** as the chain
3. Click **Create Node**

![RPC API setup page](/images/builders/integrations/indexers/moralis/moralis-8.webp)

Click **Create Node**, and your Moonbeam node will be up and running in seconds, ready to handle your RPC requests.
Your RPC endpoint will be generated for you to easily copy, and your Moonbeam node will be up and running in seconds, ready to handle your RPC requests. You can view your nodes at any time from your dashboard.

![node ready page](/images/builders/integrations/indexers/moralis/moralis-9.webp)

And that's it! Hope this guide has been helpful. For advance features and more complex use cases, refer to [its official documentation](https://docs.moralis.io/) for further details.

![node ready page](/images/builders/integrations/indexers/moralis/moralis-9.webp)
--8<-- 'text/_disclaimers/third-party-content.md'
Binary file modified images/builders/integrations/indexers/moralis/moralis-1.webp
Binary file not shown.
Binary file modified images/builders/integrations/indexers/moralis/moralis-2.webp
Binary file not shown.
Binary file modified images/builders/integrations/indexers/moralis/moralis-3.webp
Binary file not shown.
Binary file modified images/builders/integrations/indexers/moralis/moralis-4.webp
Binary file not shown.
Binary file modified images/builders/integrations/indexers/moralis/moralis-5.webp
Binary file not shown.
Binary file modified images/builders/integrations/indexers/moralis/moralis-6.webp
Binary file not shown.
Binary file modified images/builders/integrations/indexers/moralis/moralis-7.webp
Binary file not shown.
Binary file modified images/builders/integrations/indexers/moralis/moralis-8.webp
Binary file not shown.
Binary file modified images/builders/integrations/indexers/moralis/moralis-9.webp
Binary file not shown.

0 comments on commit f095b32

Please sign in to comment.