block - Cosmos

Example code for the block JSON-RPC method. Complete guide on how to use block JSON-RPC in GetBlock Web3 documentation.

Returns the block at a specific height, including full block header, transactions, and validator commit. If height is omitted, returns the latest block.

Parameters

Parameter
Type
Required
Description

height

integer

No

Block height (decimal). Defaults to the latest block if omitted

Request Example

# JSON-RPC over HTTP POST (canonical)
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/block' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "block",
    "params": {
        "height": 23456789
    },
    "id": "getblock.io"
}'

# URI over HTTP GET (alternate, for simple methods)
curl --location --request GET 'https://go.getblock.io/<ACCESS-TOKEN>/block?height=23456789'

Response Example

Response Parameters

Field
Type
Description

result.block_id.hash

string

Block hash (32 bytes hex)

result.block.header.chain_id

string

Chain ID

result.block.header.height

string

Block height

result.block.header.time

string

ISO 8601 block timestamp

result.block.header.proposer_address

string

Address of the validator that proposed this block

result.block.data.txs

array of string

Base64-encoded transaction bytes

result.block.last_commit

object

Commit signatures from validators on the previous block

Use Cases

  • Block explorers showing full block contents

  • Indexers replaying historical blocks

  • Validator monitoring (proposer rotation tracking)

Error Handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid <ACCESS-TOKEN>

-32602

Invalid params

Request parameters are missing or malformed

-32603

Internal error

Server-side error while processing the request

429

Too Many Requests

Rate limit exceeded for your plan

SDK Integration

Last updated

Was this helpful?