Skip to content

feat(foundations): normalized hash#1881

Draft
memearchivarius wants to merge 5 commits intomainfrom
1877-normalized-hash
Draft

feat(foundations): normalized hash#1881
memearchivarius wants to merge 5 commits intomainfrom
1877-normalized-hash

Conversation

@memearchivarius
Copy link
Collaborator

Closes #1877

This PR adds a new page about the normalized hash

@github-actions

This comment has been minimized.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates—I've left a couple of suggestions in foundations/messages to better align with the style guide; please apply the inline suggestions.

@novusnota novusnota changed the title feat: Normalized hash feat(foundations): normalized hash Mar 9, 2026
@github-actions

This comment has been minimized.


## Why normalization is needed

In TON, an external-in message can be constructed and packed in different ways that are all logically identical. Fields such as the source address (`src`), the `import_fee`, and the state initialization (`init`) can vary depending on the sender's implementation or the API provider processing the message.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't say that these variants are logically identical. We calculate normalized hash only for message lookup. Init field actually matters and actively used. Provider do not change the message content normally, it just calculated the hash from slightly different structure

- The wallet contract is never deleted.

<Aside type="note">
For dApps interacting with user wallets via TON Connect, or for exchanges controlling their outbound external messages, it is safe to reference traces using the normalized hash. This applies even before the transactions are finalized.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get this paragraph. How outbound external messages are connected?

```typescript
import { beginCell, Cell, Address } from "@ton/core";

function normalizeExternalMessage(destAddress: Address, bodyCell: Cell): Cell {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more like buildNormalizedExtIn(), not normalize

3. **InitState (`init`)**: Set to `nothing$0`.
4. **Body (`body:(Either X ^X)`)**: Always store as a reference (`^X`). The content of the body itself is included without modification.

After constructing the cell with these standardized values, calculate its standard [cell hash](/foundations/serialization/cells) (the SHA-256 of the root cell).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is misleading -> (the SHA-256 of the root cell).


## Uniqueness constraints

The normalized message hash is **not** a globally unique identifier across the entire blockchain. It is possible for custom smart contracts to process identical external messages that produce the same normalized hash, resulting in multiple distinct transaction chains.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as this paragraph exists (and it actually should), you should provide some guidance on what to do if someone need a globally unique identifier, maybe guide them to transactions or suggest LT + message

Copy link
Collaborator

@Shvandre Shvandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new article brings very little additional info and duplicates significant part of message-lookup article. Consider removing theoretical info from message-lookup or on the opposite hand, expand the message-lookup acticle using new info. The main issue is same as were in old docs, I can't clearly see how the information is divided into the articles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Messages > Normalized hash] Create a new page below external-in

3 participants