A TON block is a protocol-level record produced by a validator for a specific chain and shard, rather than a single globally numbered object. To work with one reliably, identify its workchain, shard, and sequence number, then verify its root and file hashes and the surrounding chain metadata. This guide explains the TON block model and provides reproducible curl, JavaScript, and measurement procedures for retrieving block data through an RPC endpoint. It also distinguishes explorer convenience data from the canonical values your application should store.
The TON block model
In TON, a block is an ordered unit of blockchain state transition and transaction processing. It records changes for one chain segment at one sequence number. Unlike a simple single-chain model in which a block number uniquely identifies a block, TON block identity includes a workchain identifier, a shard identifier, and a sequence number.
The masterchain coordinates network-wide configuration and validator-related state. Workchains carry application and account activity, and workchains can be divided into shardchains as demand changes. Consequently, a block explorer may show masterchain blocks, workchain blocks, shard information, transactions, and account changes as related but distinct records.
The practical answer to “what is a TON block?” is therefore: it is a signed and hash-addressed protocol object in a particular TON shardchain, linked to its predecessor and used to advance the state of that shard. A block explorer is useful for browsing these objects, but an application should retrieve and validate the identifiers and relationships returned by its API.
- Masterchain blocks contain coordination and configuration information.
- Workchain and shardchain blocks contain activity for subsets of accounts.
- A sequence number alone is not sufficient to identify a TON block.
- A block hash identifies content; it does not replace the chain and shard coordinates.
TON chains, shards, and block relationships
TON uses an asynchronous, sharded architecture. The masterchain has its own sequence of blocks, while workchain data is organized into shardchains. A shard identifier represents a binary shard prefix; as a shard splits, related blocks can continue under different shard identifiers, and when load decreases, shards may merge. This means that “the latest TON block” is ambiguous unless you specify which chain or ask an API for the current masterchain context.
Masterchain progress is commonly used as a coordination point when applications need a consistent view of network state. A masterchain block references or describes the state of shardchains at that point. The exact relationship exposed to an application depends on the API layer: a low-level node interface may expose serialized block data and descriptors, while an indexer may expose decoded transactions and account events.
Do not infer a global transaction order from timestamps shown by an explorer. Blocks in different shards can be produced independently, and an explorer may sort records for display rather than represent a protocol ordering. For indexing, persist the chain coordinates, hashes, predecessor information, and the API's consistency marker.
- Use masterchain state as a coordination reference when the API supports it.
- Treat shard changes as expected protocol behavior, not automatically as missing data.
- Keep chain coordinates with every block and transaction record.
- Use an indexer for decoded business events and a node or RPC API for protocol-level verification.
Block identity and useful fields
A TON block identifier is commonly represented as a tuple containing workchain ID, shard, and sequence number. In API responses, these fields may be named workchain, workchain_id, shard, and seqno. The block may also include a root hash and file hash. Naming and encoding vary between APIs, so normalize them at your application boundary rather than assuming that every provider returns identical JSON.
The root hash is associated with the block's root cell, while the file hash covers the serialized block representation used by the protocol and tooling. Both are valuable for detecting an unexpected response or comparing data from two sources. A decoded transaction list, block timestamp, transaction count, and account activity are useful application fields, but they are not substitutes for the block's canonical identity.
Store numeric sequence values using a type that cannot lose precision. JavaScript's ordinary Number type is safe for current-sized integers in many block APIs, but a general-purpose indexer should parse large numeric fields as strings or BigInt when the API and serialization require it. Preserve hash strings exactly as returned, including their encoding and case conventions.
- Minimum identity: workchain ID, shard ID, and sequence number.
- Verification fields: root hash, file hash, and predecessor or reference metadata.
- Application fields: transactions, timestamps, fees, messages, and decoded events.
- Indexing fields: retrieval time, endpoint, response status, and API version.
Access assumptions and endpoint selection
The examples below assume that RPC_URL points to a TON-compatible JSON-RPC endpoint and that the endpoint accepts the method names shown. TON tooling is exposed through several API styles, including node-oriented interfaces, JSON-RPC gateways, and indexer APIs. A method that works on one gateway may be unavailable or shaped differently on another, so check the endpoint's current method documentation before putting the example into production.
For a short overview of endpoint patterns and request conventions, see the TON RPC endpoints guide. If you are selecting an endpoint for an application, compare the required network, rate limits, archival coverage, response format, and consistency guarantees rather than choosing solely on advertised latency. OnFinality's API service and RPC pricing pages provide the service-level context; concrete endpoint selection belongs in the RPC-specific guidance.
Use an environment variable instead of embedding a token in source code. If your endpoint requires an authorization header, add it through the request environment or a secret manager. Never place a production API key in browser code, a public repository, or a client-side application bundle.
- RPC_URL: a TON-compatible endpoint URL.
- RPC_TOKEN: an optional secret supplied by the endpoint provider.
- A method reference for masterchain and block queries.
- A decision on whether you need indexed transactions or raw protocol data.
Current block retrieval with curl
The following request asks a JSON-RPC gateway for current masterchain information. It is a useful first probe because the response normally supplies the current masterchain block coordinates. Method names and parameter conventions are API-specific; if your gateway documents a different method, use its equivalent rather than modifying the response heuristically.
After obtaining the coordinates, use the block query documented by the same gateway. The second request below illustrates the common pattern of passing workchain, shard, and sequence number as parameters. It is intentionally parameterized so that the result can be reproduced against your own endpoint without inventing a public URL or a sample block number.
export RPC_URL='https://RPC_URL'
export RPC_TOKEN=''
curl -sS "$RPC_URL" \
-H 'Content-Type: application/json' \
${RPC_TOKEN:+-H "Authorization: Bearer $RPC_TOKEN"} \
--data '{"jsonrpc":"2.0","id":1,"method":"getMasterchainInfo","params":{}}' \
| jq .
# Set these from the response and the endpoint documentation.
export WORKCHAIN_ID='-1'
export SHARD='SHARD_FROM_RESPONSE'
export SEQNO='SEQNO_FROM_RESPONSE'
curl -sS "$RPC_URL" \
-H 'Content-Type: application/json' \
${RPC_TOKEN:+-H "Authorization: Bearer $RPC_TOKEN"} \
--data "{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"getBlock\",\"params\":{\"workchain\":$WORKCHAIN_ID,\"shard\":\"$SHARD\",\"seqno\":$SEQNO}}" \
| jq .Programmatic inspection and normalization
A production indexer should separate transport handling from protocol normalization. First record the raw response and its request metadata. Then map provider-specific field names into an internal schema, validate that the chain coordinates are present, and reject a response that contains an RPC error or an incomplete identity.
This JavaScript example retrieves masterchain information, prints the response, and performs basic checks. It does not claim that every TON endpoint exposes the same method or response shape. Adapt the extraction paths after inspecting your provider's documented response and add schema validation before writing records to a database.
const rpcUrl = process.env.RPC_URL;
const token = process.env.RPC_TOKEN;
if (!rpcUrl) throw new Error('Set RPC_URL');
async function rpc(method, params = {}) {
const headers = { 'content-type': 'application/json' };
if (token) headers.authorization = `Bearer ${token}`;
const response = await fetch(rpcUrl, {
method: 'POST',
headers,
body: JSON.stringify({ jsonrpc: '2.0', id: Date.now(), method, params })
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const body = await response.json();
if (body.error) throw new Error(JSON.stringify(body.error));
return body.result;
}
const info = await rpc('getMasterchainInfo');
console.log(JSON.stringify(info, null, 2));
const block = info.last ?? info.last_block ?? info;
const required = ['workchain', 'shard', 'seqno'];
for (const field of required) {
if (block[field] === undefined) {
throw new Error(`Provider response is missing ${field}; check its API schema`);
}
}
console.log({
workchain: String(block.workchain),
shard: String(block.shard),
seqno: String(block.seqno),
rootHash: block.root_hash ?? block.rootHash ?? null,
fileHash: block.file_hash ?? block.fileHash ?? null
});Verification workflow and measurement table
Verification has two separate goals. Data integrity asks whether the response is complete and internally coherent; freshness asks how far the endpoint lags behind the network. Do not treat a fast HTTP response as proof of freshness, and do not treat a block displayed by an explorer as proof that your application received the same representation.
Run the same query repeatedly from a controlled host. Record the request timestamp in UTC, HTTP status, transport latency, returned workchain, shard, sequence number, root hash, file hash, and any provider-reported block time. If the endpoint supports a second independent method or a second endpoint, compare the canonical coordinates and hashes. A useful results table is:
| Run | Request UTC | HTTP status | Latency (ms) | Workchain | Shard | Seqno | Root hash | File hash | Freshness observation |
|---|---|---|---|---|---|---|---|---|---|
| 1 | record value | record value | record value | record value | record value | record value | record value | record value | record value |
| 2 | record value | record value | record value | record value | record value | record value | record value | record value | record value |
| 3 | record value | record value | record value | record value | record value | record value | record value | record value | record value |
For a meaningful sample, collect enough runs to observe normal variation and repeat during the traffic conditions that matter to your application. Publish the date, region, client, timeout, endpoint configuration, request method, and whether a cache was enabled. The values must come from your own run; no universal block interval, latency, or throughput number should be assumed.
- Integrity check: required coordinates and hashes are present and stable for the same request.
- Freshness check: compare the returned block with a trusted reference at the same time.
- Consistency check: compare two reads or two endpoints for the same block identity.
- Performance check: report median and tail latency, not only one successful request.
Troubleshooting missing or inconsistent blocks
A “block not found” response does not always indicate a protocol problem. The shard may have split or merged, the endpoint may not retain historical data, the query may use the wrong shard encoding, or the gateway may expose only indexed blocks. First confirm the workchain, shard, and sequence number as one tuple. Then retry the same tuple without changing it and inspect the endpoint's error code and archival policy.
If two responses disagree, compare more than the displayed transaction list. Check root hash, file hash, sequence number, predecessor references, and the query's consistency point. An indexer can lag a node, normalize values differently, or omit failed or internal records. A different transaction count does not by itself prove that one response is incorrect.
If requests time out or return rate-limit errors, reduce concurrency, add bounded exponential backoff, and cache immutable block responses by their full identity. Do not endlessly retry malformed parameters. For sustained indexing, use a provider plan and architecture appropriate to the workload; see the network overview, dedicated node options, and RPC endpoint guidance.
- Wrong shard encoding or missing workchain ID.
- Non-archival endpoint queried for an old block.
- Indexer lag or provider-specific response normalization.
- Rate limiting, transient transport failures, or an overly aggressive polling loop.
Explorer views, indexers, and direct node access
An explorer is the fastest way to inspect a block manually. It usually enriches protocol data with readable addresses, transaction summaries, token values, links, and charts. That convenience is valuable for debugging, but the explorer's display model may omit fields, apply labels, or combine records from multiple services.
An indexer is appropriate when your application needs searchable transactions, account history, decoded messages, or event-oriented queries. Its strengths are queryability and normalized data; its tradeoffs include ingestion lag, provider-specific schemas, and possible gaps during reorganization or service maintenance.
Direct node-oriented access is preferable when you need raw block material, protocol verification, or control over synchronization. It requires more operational work and a deeper understanding of TON serialization and shard relationships. Many production systems combine approaches: an indexed API for application reads and a second source for integrity or freshness checks.
- Explorer: human investigation and quick visual confirmation.
- Indexer: decoded, searchable application data.
- Node or low-level RPC: protocol data and independent verification.
- Hybrid design: convenience for reads plus an independent consistency signal.
Operational limits and design tradeoffs
There is no single block cadence or universal latency guarantee that applies to every TON block query. Block production, shard activity, endpoint caching, geographic distance, provider load, and the chosen API method all affect what an application observes. Treat public explorer statistics and provider claims as context, not as a substitute for measurements made with your own request path.
Historical coverage is another important boundary. A current-state endpoint may answer recent queries while rejecting older blocks, whereas an archival service may provide historical data at a different cost or latency. Define your retention requirement before selecting an endpoint, and test the oldest block your application must support.
Finally, block inclusion is not the same as application-level success. A transaction can appear in a block while an application still needs to inspect its execution result, outgoing messages, bounced status, or contract-specific event. Design confirmation logic around the state transition and business invariant you need, not around a block number alone.
A practical path from inspection to production
Start by retrieving current masterchain information and saving the complete raw response. Next, retrieve one block using its full identity, normalize the fields into your internal schema, and compare the result with an independent source. Only after those checks pass should you add pagination, historical backfills, transaction decoding, or real-time polling.
For a production indexer, make block identity a composite key, store hashes and raw payloads, record provider and retrieval metadata, and make ingestion idempotent. Handle shard topology changes explicitly, monitor lag and error rates, and alert when two sources disagree. Keep API credentials server-side and rotate them through your deployment or secret-management system.
The next step is to match the access pattern to the application: use an explorer for manual review, an indexed RPC or API for decoded reads, and a dedicated or independently verifiable node path when protocol-level availability and historical coverage are essential. The RPC pricing page can help frame capacity decisions, while the API service page describes the broader service boundary.
- Validate one current block before building a historical backfill.
- Persist composite identity, hashes, raw data, and retrieval metadata.
- Measure freshness, latency, errors, and cross-source consistency continuously.
- Choose endpoint capacity and archival coverage from observed workload requirements.