GetBlockByLimitNext2 - Tron

This method returns a range of blocks between a start height (inclusive) and an end height (exclusive) in one call.

Service

This method is served by the protocol.Wallet service.

Method

protobufrpc GetBlockByLimitNext2 (BlockLimit) returns (BlockListExtention)

Request Message

BlockLimit

FieldTypeDescription
startNumint64First block height in the range, inclusive
endNumint64End block height, exclusive

Request

bashgrpcurl -H 'x-api-key: <ACCESS-TOKEN>' \
  -d '{"startNum": 68000000, "endNum": 68000005}' \
  shared.eu-central-1.getblock.io:443 protocol.Wallet/GetBlockByLimitNext2

example.py

pythonimport grpc
# Stubs generated from java-tron's api.proto with grpcio-tools
from api import api_pb2_grpc
from core import Contract_pb2, Tron_pb2

creds = grpc.ssl_channel_credentials()
channel = grpc.secure_channel('shared.eu-central-1.getblock.io:443', creds)
metadata = [('x-api-key', '<ACCESS-TOKEN>')]
stub = api_pb2_grpc.WalletStub(channel)

response = stub.GetBlockByLimitNext2(api_pb2.BlockLimit(startNum=68000000, endNum=68000005), metadata=metadata)
print(response)

example.go

goconn, _ := grpc.Dial(
    "shared.eu-central-1.getblock.io:443",
    grpc.WithTransportCredentials(credentials.NewTLS(&tls.Config{})),
)
defer conn.Close()

client := api.NewWalletClient(conn)
ctx := metadata.AppendToOutgoingContext(
    context.Background(), "x-api-key", "<ACCESS-TOKEN>")

resp, _ := client.GetBlockByLimitNext2(ctx, &api.BlockLimit{StartNum: 68000000, EndNum: 68000005})
fmt.Println(resp)

Response Message

BlockListExtention

FieldTypeDescription
blockrepeated BlockExtentionBlocks in the requested range

Use Cases

  • Batch Indexing: Fetch a window of blocks in one request
  • Backfill: Catch up a store over a range of heights
  • Analytics: Read a contiguous span of blocks
  • Reorg Windows: Re-scan a recent range after a rollback

Error Handling

CodeStatusDescription
3INVALID_ARGUMENTA request field is missing or malformed
5NOT_FOUNDThe requested account, block, or transaction does not exist
16UNAUTHENTICATEDThe access token is missing or invalid
13INTERNALThe node failed to process the request