@lang:bytes.at
Access a single byte by index in a bytes value.
Returns: bytes
Syntax
Section titled “Syntax”@lang:bytes.at(value index)Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
value | bytes | Source bytes value |
index | number | Zero-based byte index (negative counts from the end) |
See Also
Section titled “See Also”- @bytes.slice — extract a byte range
- @at — array element access
On-chain face (@bytes.at!)
Section titled “On-chain face (@bytes.at!)”A one-byte slice of the bytes/string return of a call: the @str.at!
recipe with the Bytes category. A negative index compiles to
sub(byteLen(s), k) so it resolves against the live byte length at
assertion time.
Examples
Section titled “Examples”load lang
set $oracle 0x44fA8E6f47987339850636F88629646662444217
# The version byte leads the blobassert @bytes.at!($oracle::{blob()(bytes)} 0) == 0x01
# The checksum byte trails it, resolved against the live lengthassert @bytes.at!($oracle::{blob()(bytes)} -1) == 0xff- An out-of-range index reverts at assertion time (SliceOutOfBounds) — on-chain slicing has no silent clamp.
See Also
Section titled “See Also”assert,@bytes.slice!,@str.at!