Convert u8 type to bytes

How convert u8 on bytes ?

my confgs:

i tryied with:

let u64_value = u64::from(1_u8).to_be_bytes();
with: example


but not working…If I need to update forc or sway, how do I do it?

What error are you getting? I am unable to reproduce an issue with your example or the follow below:


use std::{primitive_conversions::u64::*, bytes_conversions::u64::*};

abi MyContract {
    fn test_function() -> bool;

impl MyContract for Contract {
    fn test_function() -> bool {
        let my_u64 = u64::from(1_u8);
        let bytes = my_u64.to_be_bytes();

        let u64_value = u64::from(1_u8).to_be_bytes();
1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.