Skip to main content
Version: Next

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: [ '0x00' ],
pending_word: '0x414243444546474849',
pending_word_len: 9
}
const result: String = stringFromByteArray(myByteArray); // ABCDEFGHI

Defined in

src/utils/calldata/byteArray.ts:19


byteArrayFromString

byteArrayFromString(myString): ByteArray

convert a JS string to a Cairo ByteArray

Parameters

NameTypeDescription
myStringstringa JS string

Returns

ByteArray

Cairo representation of a LongString

Example

const myByteArray: ByteArray = byteArrayFromStr("ABCDEFGHI");

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

Defined in

src/utils/calldata/byteArray.ts:48