POST
/
evm
eth_getLogs
curl --request POST \
  --url https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "method": "eth_getLogs",
  "params": [
    {
      "address": "0x5555555555555555555555555555555555555555",
      "fromBlock": "0x9d0c37",
      "toBlock": "0x9d0c42"
    }
  ],
  "id": 1
}'
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    {
      "address": "0x5555555555555555555555555555555555555555",
      "topics": [
        "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
        "0x000000000000000000000000fc1286eeddf81d6955edad5c8d99b8aa32f3d2aa",
        "0x0000000000000000000000005555555555555555555555555555555555555555"
      ],
      "data": "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
      "blockNumber": "0x9d0c37",
      "blockHash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
      "transactionHash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
      "transactionIndex": "0x0",
      "logIndex": "0x0",
      "removed": false
    }
  ]
}
The eth_getLogs JSON-RPC method returns event logs that match specified filter criteria. This method is essential for retrieving smart contract events, monitoring contract activity, and building event-driven applications on the blockchain.
Get your own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.

Parameters

The method takes one parameter: a filter object that specifies the criteria for log retrieval.

Filter object

  • address (string or array, optional) — Contract address(es) to filter logs from
  • fromBlock (string, optional) — Starting block number in hexadecimal (default: "latest")
  • toBlock (string, optional) — Ending block number in hexadecimal (default: "latest")
  • topics (array, optional) — Array of topic filters for event matching
  • blockhash (string, optional) — Block hash to filter logs from (alternative to block range)

Parameter details

Address filtering:
  • Single address: "0x1234..."
  • Multiple addresses: ["0x1234...", "0x5678..."]
  • Omit to get logs from all contracts
Block range:
  • fromBlock and toBlock define the range
  • Use "latest", "earliest", "pending", or hex block numbers
  • Maximum range is 50 blocks on Hyperliquid
Topic filtering:
  • Array of up to 4 topic filters (indexed event parameters) - Hyperliquid limitation
  • Each topic can be null (any value), string (exact match), or array (multiple options)
  • Topics correspond to event signature and indexed parameters

Response

The method returns an array of log objects matching the filter criteria.

Response structure

Log object:
  • address — Contract address that emitted the log
  • topics — Array of indexed event parameters (including event signature)
  • data — Non-indexed event parameters as hexadecimal string
  • blockNumber — Block number containing the log
  • blockHash — Hash of the block containing the log
  • transactionHash — Hash of the transaction that generated the log
  • transactionIndex — Index of the transaction in the block
  • logIndex — Index of the log in the transaction
  • removed — Boolean indicating if log was removed due to chain reorganization

Event decoding

Topic structure:
  • topics[0] — Event signature hash (keccak256 of event signature)
  • topics[1-3] — Indexed event parameters (if any)
  • data — Non-indexed parameters (ABI-encoded)
Event signature:
// Example: Transfer(address indexed from, address indexed to, uint256 value)
// topics[0] = keccak256("Transfer(address,address,uint256)")
// topics[1] = from address (indexed)
// topics[2] = to address (indexed)  
// data = value (non-indexed)

Event filtering

Address filtering

Single contract:
{
  "address": "0x5555555555555555555555555555555555555555",
  "fromBlock": "0x9d0c37",
  "toBlock": "0x9d0c42"
}
Multiple contracts:
{
  "address": ["0x1111...", "0x2222...", "0x3333..."],
  "fromBlock": "0x9d0c37",
  "toBlock": "0x9d0c42"
}

Topic filtering

Specific event:
{
  "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
}
Event with indexed parameters:
{
  "topics": [
    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
    "0x000000000000000000000000fc1286eeddf81d6955edad5c8d99b8aa32f3d2aa",
    null
  ]
}
Multiple event options:
{
  "topics": [
    ["0xevent1hash", "0xevent2hash"],
    null,
    "0xspecificvalue"
  ]
}

Usage example

Basic implementation

// Get logs from Hyperliquid with proper constraints
const getLogs = async (filterObject) => {
  const response = await fetch('https://hyperliquid-mainnet.core.chainstack.com/YOUR_ENDPOINT/evm', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      jsonrpc: '2.0',
      method: 'eth_getLogs',
      params: [filterObject],
      id: 1
    })
  });
  
  const data = await response.json();
  return data.result;
};

// Get Transfer events from a specific contract
const getTransferEvents = async (contractAddress, fromBlock, toBlock) => {
  // Ensure block range doesn't exceed 50 blocks (Hyperliquid limit)
  const startBlock = parseInt(fromBlock, 16);
  const endBlock = parseInt(toBlock, 16);
  
  if (endBlock - startBlock > 50) {
    throw new Error('Block range cannot exceed 50 blocks on Hyperliquid');
  }
  
  const filter = {
    address: contractAddress,
    topics: [
      "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" // Transfer event signature
    ],
    fromBlock: fromBlock,
    toBlock: toBlock
  };
  
  const logs = await getLogs(filter);
  
  // Decode Transfer events
  return logs.map(log => ({
    from: "0x" + log.topics[1].slice(26), // Remove padding
    to: "0x" + log.topics[2].slice(26),
    value: parseInt(log.data, 16),
    blockNumber: parseInt(log.blockNumber, 16),
    transactionHash: log.transactionHash
  }));
};

// Get logs with multiple topic filters (up to 4 topics on Hyperliquid)
const getFilteredLogs = async (contractAddress, fromBlock, toBlock) => {
  const filter = {
    address: contractAddress,
    topics: [
      ["0xevent1hash", "0xevent2hash"], // Multiple event types
      null, // Any value for second topic
      "0xspecificvalue", // Specific value for third topic
      null  // Any value for fourth topic (max 4 topics on Hyperliquid)
    ],
    fromBlock: fromBlock,
    toBlock: toBlock
  };
  
  return await getLogs(filter);
};

// Process logs in chunks to respect 50-block limit
const processLogsInChunks = async (contractAddress, startBlock, endBlock) => {
  const allLogs = [];
  const chunkSize = 50; // Hyperliquid limit
  
  for (let i = startBlock; i <= endBlock; i += chunkSize) {
    const chunkEnd = Math.min(i + chunkSize - 1, endBlock);
    const fromBlockHex = "0x" + i.toString(16);
    const toBlockHex = "0x" + chunkEnd.toString(16);
    
    try {
      const logs = await getTransferEvents(contractAddress, fromBlockHex, toBlockHex);
      allLogs.push(...logs);
    } catch (error) {
      console.error(`Error processing blocks ${i}-${chunkEnd}:`, error);
    }
  }
  
  return allLogs;
};

// Usage examples
const contractAddress = "0x5555555555555555555555555555555555555555";

getTransferEvents(contractAddress, "0x9d0c37", "0x9d0c42")
  .then(transfers => console.log('Transfer Events:', transfers))
  .catch(error => console.error('Error:', error));

// Process larger range in chunks
processLogsInChunks(contractAddress, 10291248, 10291348)
  .then(allLogs => console.log(`Processed ${allLogs.length} events`))
  .catch(error => console.error('Error:', error));

Hyperliquid-specific limitations

Block range constraint

50-block limit:
  • Maximum query range is 50 blocks on Hyperliquid
  • Use chunking for larger ranges
  • Process blocks in batches to respect this limit
  • Plan queries accordingly for historical analysis

Topic filtering

4-topic maximum:
  • Up to 4 topic filters are supported
  • Each topic can be null, string, or array of strings
  • Topics[0] is typically the event signature hash
  • Topics[1-3] are indexed event parameters

Filter examples

Token transfers

All transfers:
{
  "address": "0x5555555555555555555555555555555555555555",
  "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"],
  "fromBlock": "0x9d0c37",
  "toBlock": "0x9d0c42"
}
Transfers from specific address:
{
  "topics": [
    "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
    "0x000000000000000000000000fc1286eeddf81d6955edad5c8d99b8aa32f3d2aa"
  ]
}

Multiple event types

Transfers and approvals:
{
  "topics": [
    [
      "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
      "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925"
    ]
  ]
}

Example request

Shell
curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"address":"0x5555555555555555555555555555555555555555","fromBlock":"0x9d0c37","toBlock":"0x9d0c42"}],"id":1}' \
  https://hyperliquid-mainnet.core.chainstack.com/4f8d8f4040bdacd1577bff8058438274/evm

Use cases

The eth_getLogs method is essential for applications that need to:
  • Event monitoring: Monitor smart contract events within 50-block ranges
  • DeFi analytics: Track token transfers, swaps, and protocol events
  • Transaction analysis: Analyze contract interactions and state changes
  • Audit systems: Track contract activity for compliance and security
  • Portfolio tracking: Monitor user transactions and balance changes
  • Market analysis: Analyze trading activity and market events
  • Notification systems: Generate alerts based on specific events
  • Data indexing: Build event databases with chunked processing
  • Development tools: Debug and test smart contract event emissions
  • Integration services: Provide event data to external systems
On Hyperliquid, eth_getLogs supports up to 4 topics and a maximum query range of 50 blocks. For larger ranges, use chunking to process blocks in batches of 50 or fewer.

Body

application/json

Response

200 - application/json

Successful response with matching event logs

The response is of type object.