How to convert `u64` to `b256` in Sway

I want to convert u64 to b256 in Sway. How can I do that?

@fsociety

Here is an example:

let u64_1: u64 = 2u64;

let u256_from_u64: u256 = u64_1.as_u256();

let new_b256 = u256_from_u64.as_b256();

We recently added a new converting types page in the Sway book you may find useful. It will make it’s way to the docs.fuel.network site once a new version of Sway is released.

2 Likes

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