getBytes

fun getBytes(name: String, expectedLength: Int): ByteArray

Read a Bytes field. The chain MAY pad shorter values to N bytes (e.g. an unwritten cell decodes as N zero bytes), so we validate against expectedLength explicitly. A mismatch is a schema drift or a wrong call (e.g. asked for Bytes<32> on a Bytes<20> field).

Accepts two on-wire shapes — both come from the same CompactTypeBytes.fromValue getter, depending on whether the runtime pre-padded the value:

  • ByteArray — returned when the runtime wrapped the value in a Uint8Array (typical when the chain stored a shorter value and the runtime padded it to length N).

  • List<*> of BigInteger / Long / Int — returned when the underlying __nativeContractQuery JSON arrived as a plain Array<number> and the runtime passed it through unchanged (the val.length == this.length branch of CompactTypeBytes.fromValue).

Each list element must fit in 0..255; otherwise this is a schema mismatch.