Skip to main content

Introduction

In this tutorial, you’ll learn how to retrieve internal transactions for any wallet address using the Moralis API. Internal transactions are calls made between smart contracts during a transaction’s execution, including ETH transfers from contracts. These are not visible in standard transaction lists but are important for tracking the complete flow of funds. We’ll use the following Moralis API endpoint:

Prerequisites

Step 1: Set Up Your Project

Create a new directory for your project and initialize it:
mkdir get-internal-transactions && cd get-internal-transactions
npm init -y

Step 2: Create the Script

Create a file called index.js and add the following code:
// index.js
const API_KEY = 'YOUR_API_KEY';
const WALLET_ADDRESS = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';

async function getInternalTransactions() {
  const response = await fetch(
    `https://deep-index.moralis.io/api/v2.2/${WALLET_ADDRESS}/verbose?chain=eth&include=internal_transactions`,
    {
      headers: {
        'X-API-Key': API_KEY,
      },
    }
  );

  const data = await response.json();
  console.log(JSON.stringify(data, null, 2));
}

getInternalTransactions();
Replace YOUR_API_KEY with your actual Moralis API key.

Step 3: Run the Script

Execute the script to fetch the internal transactions:
node index.js

Example Response

{
  "page_size": 100,
  "page": 1,
  "cursor": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "result": [
    {
      "hash": "0x1ed85b3757a6d31d01a4d6677fc52fd3911d649a0af21d29f3e2c2f10c82e12c",
      "nonce": "1848059",
      "transaction_index": "73",
      "from_address": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
      "to_address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
      "value": "100000000000000000",
      "gas": "30000",
      "gas_price": "22434567890",
      "receipt_cumulative_gas_used": "4923073",
      "receipt_gas_used": "21000",
      "receipt_status": "1",
      "block_timestamp": "2023-01-01T01:28:23.000Z",
      "block_number": "16308190",
      "block_hash": "0x3c6d5e2a1b2b1b2b1b2b1b2b1b2b1b2b1b2b1b2b1b2b1b2b1b2b1b2b1b2b1b2b",
      "internal_transactions": [
        {
          "transaction_hash": "0x1ed85b3757a6d31d01a4d6677fc52fd3911d649a0af21d29f3e2c2f10c82e12c",
          "block_number": 16308190,
          "block_hash": "0x3c6d5e2a1b2b1b2b1b2b1b2b1b2b1b2b1b2b1b2b1b2b1b2b1b2b1b2b1b2b1b2b",
          "type": "CALL",
          "from": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
          "to": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
          "value": "100000000000000000",
          "gas": "2300",
          "gas_used": "0",
          "input": "0x",
          "output": "0x"
        }
      ]
    }
  ]
}

Understanding the Response

FieldDescription
hashParent transaction hash
from_addressAddress that initiated the transaction
to_addressAddress the transaction was sent to
valueETH value transferred (in wei)
receipt_statusTransaction status (1 = success, 0 = failed)
block_timestampWhen the transaction was mined
internal_transactionsArray of internal calls within this transaction
internal_transactions.typeType of internal call (CALL, CREATE, DELEGATECALL, etc.)
internal_transactions.fromAddress initiating the internal call
internal_transactions.toAddress receiving the internal call
internal_transactions.valueETH value transferred internally (in wei)

Next Steps