Skip to content

Commit d2ffb20

Browse files
committed
docs: update int-to-bytes table
1 parent a8ba6b1 commit d2ffb20

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

website/docs/language/types.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,14 @@ Using `bytes20 placeholderPkh= bytes20(0)` will generate a 20 byte zero-array pr
185185
`bytes20 placeholderPkh= 0x0000000000000000000000000000000000000000` will actually take 20 bytes of space in your contract.
186186
:::
187187

188-
Casting an integer to a fixed-size byte-length can be a very important when storing local state in an nftCommitment. Developers need to consider what the preferable fixed-size length is for each indivual case depending on the interger range. Below we add a table with information on the maximum integer size for satoshis and fungible CashTokens:
189-
190-
| Integer Type | Maximum amount | Max Byte Size |
191-
| -------------- | ---------------------- | ---------------------------------- |
192-
| Satoshis | 2.1 quadrillion | 6 bytes (5 bytes for 1 quadrillion)|
193-
| CashTokens | 9223 quadrillion | 8 bytes for max supply token |
188+
Casting an integer to a fixed-size byte-length can be a very important when storing local state in an nftCommitment. When casting a script number to bytes, developers need to consider what the preferable fixed-size length is for each indivual case depending on the interger range. Below we add a table with info on the maximum integer size for common cases:
189+
190+
| Integer Type | Max integer value | Max Byte Size in Script Number Format |
191+
| -------------- | -----------------------------------| ---------------------------------------|
192+
| Satoshis | 2.1 quadrillion (21,000,000 BCH) | 7 bytes |
193+
| CashTokens | 9.2 quintillion (`2^63 - 1`) | 8 bytes for max supply token |
194+
| Locktime | 4 bytes uInt (`2^32 - 1`) | 6 bytes |
195+
| SequenceNumber | 4 bytes uInt (`2^32 - 1`) | 6 bytes |
194196

195197
:::info
196198
VM numbers follow Script Number format (A.K.A. CSCriptNum), to convert VM number to bytes or the reverse, it's recommended to use helper functions for these conversions from libraries like Libauth.

0 commit comments

Comments
 (0)