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”
- “chiliz”
- “0x15b38”
- “chiliz testnet”
- “0x15b32”
- “gnosis”
- “0x64”
- “gnosis testnet”
- “0x27d8”
- “base”
- “0x2105”
- “base testnet”
- “0x14a33”
- “base sepolia”
- “0x14a34”
- “optimism”
- “0xa”
- “holesky”
- “0x4268”
- “polygon amoy”
- “0x13882”
- “linea”
- “0xe708”
The chain to query   “eth” “eth”
include enum[str]:
- “internal_transactions”
If the result should contain the internal transactions.   ”” ””

get_block_stats

evm_api.block.get_block_stats()

Get the stats for a block

Example

from moralis import evm_api

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

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

print(result)

Parameters

Name Type Description Required Default Example
block_number_or_hash str The block number or hash 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”
- “chiliz”
- “0x15b38”
- “chiliz testnet”
- “0x15b32”
- “gnosis”
- “0x64”
- “gnosis testnet”
- “0x27d8”
- “base”
- “0x2105”
- “base testnet”
- “0x14a33”
- “base sepolia”
- “0x14a34”
- “optimism”
- “0xa”
- “holesky”
- “0x4268”
- “polygon amoy”
- “0x13882”
- “linea”
- “0xe708”
The chain to query   “eth” “eth”

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 (format in seconds or datestring 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”
- “chiliz”
- “0x15b38”
- “chiliz testnet”
- “0x15b32”
- “gnosis”
- “0x64”
- “gnosis testnet”
- “0x27d8”
- “base”
- “0x2105”
- “base testnet”
- “0x14a33”
- “base sepolia”
- “0x14a34”
- “optimism”
- “0xa”
- “holesky”
- “0x4268”
- “polygon amoy”
- “0x13882”
- “linea”
- “0xe708”
The chain to query   “eth” “eth”