Skip to content

Commit c8320cc

Browse files
committed
Remove incorrect section about bytes => bytesX casting
1 parent a10104e commit c8320cc

1 file changed

Lines changed: 0 additions & 12 deletions

File tree

website/docs/language/types.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,6 @@ Casting an integer to a fixed-size byte-length can be a very important when stor
214214
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.
215215
:::
216216

217-
### Bytes to BytesX Casting
218-
219-
If you do need to pad bytes to a specific length, you can convert the bytes to `int` first, and then cast to the bounded `bytes` type. This will pad the bytes with zeros to the specified length, like specified in the *Int to Byte Casting* section above.
220-
221-
#### Example
222-
```solidity
223-
bytes10 data = nftCommitment.split(10)[0];
224-
// First convert 'bytes' type to 'int' to cast with padding
225-
bytes20 paddedData = bytes20(int(data));
226-
require(storedContractState == paddedData);
227-
```
228-
229217
### Semantic Byte Casting
230218

231219
When casting unbounded `bytes` types to bounded `bytes` types (such as `bytes20` or `bytes32`), this is a purely semantic cast. The bytes are not padded with zeros, and no checks are performed to ensure the cast bytes are of the correct length. This can be helpful in certain cases, such as `LockingBytecode`, which expects a specific length input.

0 commit comments

Comments
 (0)