Skip to content

Commit e464c4d

Browse files
mr-zwetsrkalis
authored andcommitted
remove warning integer casting, add docs about Semantic Byte Casting
1 parent e8b7287 commit e464c4d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

website/docs/language/types.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,15 @@ When casting integer types to bytes of a certain size, the integer value is padd
178178
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.
179179
:::
180180

181+
### Semantic Byte Casting
181182

182-
:::caution
183-
When casting bytes types to integer, you should be sure that the bytes value fits inside a 64-bit signed integer, or the script will fail.
184-
:::
183+
Bytes to bytes casting is just semantic and can be helpful for working with `LockingBytecode` global functions which expect a specific length input. To utilize byte-padding, convert to `int` and utilize the integer padding.
184+
185+
#### Example
186+
```solidity
187+
bytes pkh = nftcommitment.split(20)[0];
188+
bytes25 lockingBytecode = new LockingBytecodeP2PKH(bytes20(pkh)):
189+
```
185190

186191
## Operators
187192
An overview of all supported operators and their precedence is included below. Notable is a lack of exponentiation, since these operations are not supported by the underlying Bitcoin Script.

0 commit comments

Comments
 (0)