getMasterchainInfo
https://triport.io/rpc/tonReturns the current masterchain block, state root, and zero-state reference.
getMasterchainInfo calls liteServer.getMasterchainInfo and returns the
selected server's current masterchain reference. The result includes the latest
full block ID, its state root hash, and the zero-state block ID.
Use it to obtain a starting block reference for getBlock, getBlockHeader,
or a nearby lookupBlock request. The last.seqno value is the selected
liteserver's view of the head; it is not a transaction logical time.
Successful responses pass the TON freshness gate before they are served. This
is a current-head method and does not establish that the same liteserver retains
every block between the returned init and last references.
Parameters
JSON-RPC params is an empty by-name object.
Params: object (by-name).
——optionalparams: {}.Response
Response fields
| Field | Type | Description |
|---|---|---|
jsonrpc | string | JSON-RPC protocol version. |
id | number or string | Correlates the response with the request. |
result | object | Current masterchain information. |
result.last | object | Selected server's latest full masterchain block ID. |
result.state_root_hash | string | State root hash associated with the current reference. |
result.init | object | Masterchain zero-state block ID. |
result.last.workchain | integer | Workchain ID. |
result.last.shard | string | Signed shard ID as decimal text. |
result.last.seqno | integer | Current masterchain sequence number. |
result.last.root_hash | string | Current block root hash. |
result.last.file_hash | string | Current block file hash. |
The JSON is copied without invention from the accepted live fixture.
Errors
See TON errors for the shared envelope.
| Code | Meaning | When it happens |
|---|---|---|
-32602 | Invalid params | A non-empty or positional parameter structure is malformed. |
-32601 | Method not found | The method is outside the published read-only catalog. |
401 | Unauthorized | The API key is missing or invalid. |
429 | Rate limited | The ton_read_rpc budget is exceeded. |
Examples
const response = await fetch("https://triport.io/rpc/ton", {
method: "POST",
headers: { "x-token": process.env.TRIPORT_API_KEY, "Content-Type": "application/json" },
body: JSON.stringify({ jsonrpc: "2.0", id: "head", method: "getMasterchainInfo", params: {} }),
});
const { result: masterchain } = await response.json();Notes
- Use
lastas a full block reference;initidentifies zero state and does not promise that all intervening data is retained. - Two liteservers answered from genesis, but only one showed confirmed
continuity;
ls-17had a measured gap. Pruned servers had a floor of 86 860 000. - This is a polling method because TON WebSocket subscriptions are not published. Public HTTP gateways are not used as upstreams.
- Named params and response correlation by
idalso apply inside batches. - Related methods:
getBlock,getBlockHeader, andgetTime.