get_block

Returns block metadata for a block number, tag, or hash. Set include_transactions to request expanded transaction objects in transactions_full; otherwise transactions contains hashes.

Example

Needs RPC · RPC required

1
SELECT number, hash, timestamp
2
FROM get_block($client);
Notebook ready in readonly mode.

API reference

Exact signatures with descriptions, requirements, inputs, returns, and examples.

get_block(CLIENT) # RPC required

Returns the provider's latest block with transaction hashes but without expanded transaction objects.

Inputs

Name Type Use
client CLIENT

Attached live CLIENT for the chain containing the requested block.

required positional

Result columns

NameType
hashBYTES32

Block hash.

parent_hashBYTES32

Parent block hash.

minerADDRESS

Execution-fee recipient.

numberBLOCK_NUMBER

Block height.

timestampTIMESTAMP

Block time in UTC.

Showing fewer

Block metadata row. Returns one block row. transactions contains transaction hashes; transactions_full contains expanded transaction objects when include_transactions is true.

Guidance

Reproducible block reads

Use an explicit block_number or finalized block hash when a query must be repeatable.

latest, safe, and finalized are moving tags whose referenced block can change between runs.

Choose the transaction representation

The default overload returns transaction hashes in transactions.

Set include_transactions to true and read transactions_full when sender, recipient, value, fee, or calldata fields are required.

Transaction columns

When include_transactions is false, use transactions for transaction hashes.

When include_transactions is true, use transactions_full for expanded transaction objects.

Additional overloads

get_block(CLIENT, BIGINT) # RPC required

Returns the block at an exact decimal height with transaction hashes only.

Inputs

Name Type Use
client CLIENT

Attached live CLIENT for the chain containing the requested block.

required positional
block_number BIGINT

Block height, canonical tag such as latest or finalized, or a 0x-prefixed block hash.

required positional

Result columns

NameType
hashBYTES32

Block hash.

parent_hashBYTES32

Parent block hash.

minerADDRESS

Execution-fee recipient.

numberBLOCK_NUMBER

Block height.

timestampTIMESTAMP

Block time in UTC.

Showing fewer
get_block(CLIENT, VARCHAR) # RPC required

Returns a block selected by a canonical tag or 0x-prefixed hash, with transaction hashes only.

Inputs

Name Type Use
client CLIENT

Attached live CLIENT for the chain containing the requested block.

required positional
block_tag_or_hash VARCHAR

Block height, canonical tag such as latest or finalized, or a 0x-prefixed block hash.

required positional

Result columns

NameType
hashBYTES32

Block hash.

parent_hashBYTES32

Parent block hash.

minerADDRESS

Execution-fee recipient.

numberBLOCK_NUMBER

Block height.

timestampTIMESTAMP

Block time in UTC.

Showing fewer

Overload examples

Named parameters · RPC required

1
-- Summarize the provider's finalized block
2
SELECT
3
number,
4
length(transactions) AS transaction_count,
5
gas_used,
6
gas_limit,
7
round(100.0 * gas_used::DOUBLE / gas_limit::DOUBLE, 2) AS gas_utilization_pct
8
FROM get_block($client, 'finalized');
get_block(CLIENT, BIGINT, BOOLEAN) # RPC required

Returns a block by exact height and optionally populates transactions_full with expanded transaction objects.

Inputs

Name Type Use
client CLIENT

Attached live CLIENT for the chain containing the requested block.

required positional
block_number BIGINT

Block height, canonical tag such as latest or finalized, or a 0x-prefixed block hash.

required positional
include_transactions BOOLEAN

When true, request expanded transaction objects in transactions_full. When false, transactions contains hashes.

required positional

Result columns

NameType
hashBYTES32

Block hash.

parent_hashBYTES32

Parent block hash.

minerADDRESS

Execution-fee recipient.

numberBLOCK_NUMBER

Block height.

timestampTIMESTAMP

Block time in UTC.

Showing fewer

Overload examples

Named parameters · RPC required

1
-- Largest native-value transfers in the block containing the documented transaction
2
SELECT
3
(tx).hash AS transaction_hash,
4
(tx)."from" AS sender,
5
(tx)."to" AS recipient,
6
format_ether((tx).value) AS eth_value
7
FROM get_block($client, 25433824, true),
8
UNNEST(transactions_full) AS expanded(tx)
9
ORDER BY sort_key((tx).value) DESC
10
LIMIT 10;
get_block(CLIENT, VARCHAR, BOOLEAN) # RPC required

Returns a tag- or hash-selected block and optionally populates transactions_full with expanded transaction objects.

Inputs

Name Type Use
client CLIENT

Attached live CLIENT for the chain containing the requested block.

required positional
block_tag_or_hash VARCHAR

Block height, canonical tag such as latest or finalized, or a 0x-prefixed block hash.

required positional
include_transactions BOOLEAN

When true, request expanded transaction objects in transactions_full. When false, transactions contains hashes.

required positional

Result columns

NameType
hashBYTES32

Block hash.

parent_hashBYTES32

Parent block hash.

minerADDRESS

Execution-fee recipient.

numberBLOCK_NUMBER

Block height.

timestampTIMESTAMP

Block time in UTC.

Showing fewer

Related functions

Category and tags

Category
Chain reads
Tag
RPC