Skip to content

[mkdocs] docs: add transfer mosaic tutorial#889

Open
zero4862 wants to merge 2 commits into
NemProject:new-docsfrom
zero4862:docs-transfer-mosaic
Open

[mkdocs] docs: add transfer mosaic tutorial#889
zero4862 wants to merge 2 commits into
NemProject:new-docsfrom
zero4862:docs-transfer-mosaic

Conversation

@zero4862

@zero4862 zero4862 commented Jun 8, 2026

Copy link
Copy Markdown

Adds a tutorial to transfer mosaics that builds on #883

@zero4862 zero4862 requested a review from segfaultxavi June 8, 2026 16:20
@zero4862 zero4862 marked this pull request as ready for review June 8, 2026 16:21
- devbook/accounts/testnet-faucet.md
- devbook/accounts/query-balance.md
- Transactions:
- devbook/transactions/transfer-mosaics.md

@segfaultxavi segfaultxavi Jun 9, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wrong indentation! It should be under Tutorials.

I've already pushed the fix for the XEM transfer tutorial. Please rebase.

print(f' {MOSAIC_ID}: divisibility {divisibility}, supply {supply}')
# [<step-4]
# Calculate the transaction fee [>step-5]
quantity = QUANTITY * (10 ** divisibility)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Better call this variable atomic_quantity.
Using only the case is confusing.

quantity = QUANTITY * (10 ** divisibility)
multiplier = 1
amount = multiplier * 1_000_000
if supply <= 10_000 and 0 == divisibility:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Constant should be on the left (10_000 >= supply), as in the JS case.

I hate this style, but we have to be consistent.

# Tiny, indivisible mosaics pay a flat 0.05 XEM
fee = 50_000
else:
total_quantity = supply * 10 ** divisibility

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This variable name is confusing too, I would call it atomic_supply, just like before.

Math.max(1, Math.floor(xemEquivalent / 10_000)));
// 3. Supply discount (larger for scarcer mosaics)
const supplyAdjustment = Math.floor(
0.8 * Math.log(9_000_000_000_000_000 / totalQuantity));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Such big integers make me nervous. Are we sure we're not hitting any precission issues?
Should we use BigInt constants? But then Math.log does not work...

Each entry contains the mosaic's properties, including `divisibility`.
* The <get:/mosaic/supply> endpoint returns the current total supply.

### Calculating the Transaction Fee

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be nice to mention that this fee calculation is more complex than the one in the XEM transfer tutorial.

# Calculate the transaction fee [>step-5]
quantity = QUANTITY * (10 ** divisibility)
multiplier = 1
amount = multiplier * 1_000_000

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

amount is super ambiguous in this tutorial. I would call it something like scaled_multiplier.

* The mosaic's name, also as a byte string.
* The quantity, given in the mosaic's **atomic units** (calculated in the previous step).

When mosaics are attached, the top-level `amount` is no longer the XEM amount.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This paragraph should contain a link to the XEM Amount section in the Transfer Transaction Textbook page.

It becomes a multiplier applied to every listed mosaic, where `1_000_000` represents a factor of one.
Setting `amount` to `1_000_000` sends each mosaic at the quantity given in its entry.

!!! info "Sending XEM alongside other mosaics"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Useful box indeed, but we better explain why this is needed: once the mosaics array is not empty the transaction does not default to send amount XEMs, so you need to send them as regular mosaics and amount behaves like a multiplier.


!!! warning "Mosaics with a levy"

Some mosaics carry a [levy](../../textbook/mosaics.md#levy): an additional fee paid to a third-party

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add a glossary definition for "levy" in the Textbook, so it look nicer here :)

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.

2 participants