Skip to main content

Don't have an API key yet?

Sign-up to Moralis to get your free API key and start building today.

Get Your Free API Key
Version: 2.2

Get block by version

🚨Aptos: Confirmed Deprecation (60 Days Notice)

Aptos mainnet and testnet will be discontinued on November 22nd, in line with the network’s deprecation of their v1 Indexers. We recommend exploring alternative providers, which you can find at Aptos APIs.

GEThttps://mainnet-aptos-api.moralis.io/blocks/by_version/:version

Get block by specific ledger version.

PATH PARAMS
versionnumberrequired
Ledger version to lookup block information for.
QUERY PARAMS
with_transactionsboolean
If set to true, include all transactions in the block
Responses
API KEY
import Moralis from 'moralis';

try {
await Moralis.start({
apiKey: "YOUR_API_KEY"
});

const response = await Moralis.AptosApi.blocks.getBlockByVersion({
"network": "mainnet"
});

console.log(response);
} catch (e) {
console.error(e);
}
Response Example
{
"block_height": "32425224034",
"block_hash": "32425224034",
"block_timestamp": "32425224034",
"first_version": "32425224034",
"last_version": "32425224034",
"transactions": [
{
"hash": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1",
"sender": "0x88fbd33f54e1126269769780feb24480428179f552e2313fbe571b72e62a1ca1",
"sequence_number": "32425224034",
"max_gas_amount": "32425224034",
"gas_unit_price": "32425224034",
"expiration_timestamp_secs": "32425224034",
"payload": {
"type": "",
"function": "",
"type_arguments": [
""
],
"arguments": [
""
]
},
"signature": {
"type": "",
"signature": "",
"public_key": ""
}
}
]
}