Namespace: byteArray
Functions
stringFromByteArray
▸ stringFromByteArray(myByteArray): string
convert a Cairo ByteArray to a JS string
Parameters
| Name | Type | Description |
|---|---|---|
myByteArray | ByteArray | Cairo 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
| Name | Type | Description |
|---|---|---|
targetString | string | a JS string |
Returns
Cairo representation of a LongString
Example
const myByteArray: ByteArray = byteArrayFromString('ABCDEFGHI');
Result is : { data: [], pending_word: '0x414243444546474849', pending_word_len: 9 }