Skip to main content
Version: 2.2

How to get multi-chain activity of an address

Don't have an API key yet?

Start using this API for your project today.

Get your free API key

Step 1: Setup Moralis

Read the article Setting Up Moralis: Getting Started and make sure to finish all the steps. Only after that you can go ahead to complete this guide.

Step 2: Get multi-chain activity of a wallet address

In order to get the chain activity, Moralis provides you a getWalletActiveChains endpoint to do so.

To use the getWalletActiveChains endpoint, you'll primarily need the parameter address. Optionally, you can also specify the parameter chains to filter the activity for specific blockchain networks.

tip

Providing the chains parameter is optional. This endpoint primarily requires the address parameter. If you choose not to specify chains, the endpoint will return activity across all supported chains for the given address.

Once you've obtained the address you can copy the following code:

const Moralis = require("moralis").default;
const { EvmChain } = require("@moralisweb3/common-evm-utils");

const runApp = async () => {
await Moralis.start({
apiKey: "YOUR_API_KEY",
// ...and any other configuration
});

const address = "0x26fcbd3afebbe28d0a8684f790c48368d21665b5";

const chains = [EvmChain.ETHEREUM, EvmChain.BSC, EvmChain.POLYGON];

const response = await Moralis.EvmApi.wallets.getWalletActiveChains({
address,
chains,
});

console.log(response.toJSON());
}

runApp();

Step 3: Run the script

To run the script, enter the following command:

node index.js

In your terminal, you should see the following JSON response with the data about chain activity:

{
"address": "0x26fcbd3afebbe28d0a8684f790c48368d21665b5",
"active_chains": [
{
"chain": "eth",
"chain_id": "0x1",
"first_transaction": {
"block_timestamp": "2015-09-28T08:24:43.000Z",
"block_number": "302086",
"transaction_hash": "0x9b629147b75dc0b275d478fa34d97c5d4a26926457540b15a5ce871df36c23fd"
},
"last_transaction": {
"block_timestamp": "2023-07-18T22:00:59.000Z",
"block_number": "17722945",
"transaction_hash": "0xde35173f86138e2c0accd780b08cf986009c6ac577d441fe49050764666493e4"
}
},
{
"chain": "bsc",
"chain_id": "0x38",
"first_transaction": {
"block_timestamp": "2022-03-22T08:29:46.000Z",
"block_number": "16275630",
"transaction_hash": "0x144bf655f6ad276c42e6380997db73eff30725923a2c089fb7e57b3e3d07a32b"
},
"last_transaction": {
"block_timestamp": "2023-06-12T11:37:50.000Z",
"block_number": "29035694",
"transaction_hash": "0x18e5043a363ba33ad2320f7980efd50372bc021fb1b3041e7831db9058492551"
}
},
{
"chain": "polygon",
"chain_id": "0x89",
"first_transaction": {
"block_timestamp": "2021-07-20T02:38:06.000Z",
"block_number": "17055069",
"transaction_hash": "0x482328171e8549129acd9dde9408602410909adac2e4e46a9591592b2e0e1a24"
},
"last_transaction": {
"block_timestamp": "2023-07-14T08:55:47.000Z",
"block_number": "45062599",
"transaction_hash": "0x7dd9979c5d57ac74c2787f47e8ff9942d0eebf6375ab5262ac48d0455b9c3de3"
}
}
]
}

Congratulations 🥳 you just found the activity of a wallet address on multiple chains with only a few lines of code using the Moralis Wallet API!

API Reference

If you want to know more details on the endpoint and optional parameters, check out:

Support

If you face any trouble following the tutorial, feel free to reach out to our community engineers in our Discord or Forum to get 24/7 developer support.