[mkdocs] docs: add transfer mosaic tutorial#889
Conversation
| - devbook/accounts/testnet-faucet.md | ||
| - devbook/accounts/query-balance.md | ||
| - Transactions: | ||
| - devbook/transactions/transfer-mosaics.md |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Please add a glossary definition for "levy" in the Textbook, so it look nicer here :)
Adds a tutorial to transfer mosaics that builds on #883