Moralis-Python-SDK

block API:

evm_api.block


get_block

evm_api.block.get_block()

Get the contents of a block given the block hash.

Example

from moralis import evm_api

api_key = "YOUR_API_KEY"
params = {
    "block_number_or_hash": "15863321", 
    "chain": "eth", 
    "include": "", 
}

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

print(result)

Parameters

Name Type Description Required Default Example
block_number_or_hash str The block number or block hash Yes   “15863321”
chain enum[str]:
- “eth”
- “0x1”
- “goerli”
- “0x5”
- “sepolia”
- “0xaa36a7”
- “polygon”
- “0x89”
- “mumbai”
- “0x13881”
- “bsc”
- “0x38”
- “bsc testnet”
- “0x61”
- “avalanche”
- “0xa86a”
- “fantom”
- “0xfa”
- “palm”
- “0x2a15c308d”
- “cronos”
- “0x19”
- “arbitrum”
- “0xa4b1”
The chain to query   “eth” “eth”
include enum[str]:
- “internal_transactions”
If the result should contain the internal transactions.   ”” ””

get_date_to_block

evm_api.block.get_date_to_block()

Get the closest block given the date.

Example

from moralis import evm_api

api_key = "YOUR_API_KEY"
params = {
    "date": "", 
    "chain": "eth", 
}

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

print(result)

Parameters

Name Type Description Required Default Example
date str Unix date in milliseconds or a datestring (any format that is accepted by momentjs) Yes   ””
chain enum[str]:
- “eth”
- “0x1”
- “goerli”
- “0x5”
- “sepolia”
- “0xaa36a7”
- “polygon”
- “0x89”
- “mumbai”
- “0x13881”
- “bsc”
- “0x38”
- “bsc testnet”
- “0x61”
- “avalanche”
- “0xa86a”
- “fantom”
- “0xfa”
- “palm”
- “0x2a15c308d”
- “cronos”
- “0x19”
- “arbitrum”
- “0xa4b1”
The chain to query   “eth” “eth”