Skip to main content
Version: 6.11.0

Namespace: byteArray

Functions​

stringFromByteArray​

â–¸ stringFromByteArray(myByteArray): string

convert a Cairo ByteArray to a JS string

Parameters​

NameTypeDescription
myByteArrayByteArrayCairo representation of a LongString

Returns​

string

a JS string

Example

const myByteArray = {
data: [],
pending_word: '0x414243444546474849',
pending_word_len: 9,
};
const result: String = stringFromByteArray(myByteArray); // ABCDEFGHI

Defined in​

src/utils/calldata/byteArray.ts:19


byteArrayFromString​

â–¸ byteArrayFromString(targetString): ByteArray

convert a JS string to a Cairo ByteArray

Parameters​

NameTypeDescription
targetStringstringa JS string

Returns​

ByteArray

Cairo representation of a LongString

Example

const myByteArray: ByteArray = byteArrayFromString('ABCDEFGHI');

Result is : { data: [], pending_word: '0x414243444546474849', pending_word_len: 9 }

Defined in​

src/utils/calldata/byteArray.ts:48