How to convert b256 to a number and vice versa?

I’m looking for a way to convert a b256 variable to u256 and vice versa.

I found this topic and it looks like there should be a way of converting it, but I couldn’t find an appropriate function/trait in Sway.

let val: b256 = 0x0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20;
let result = val.as_u256();

See more methods here


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