How to convert address like "fuel1..." to the "0x..." type?

Hey guys
In sway examples, I found an example wallet smart contract.
In this example, author defines the variable OWNER_ADDRESS using an address like 0x...

const OWNER_ADDRESS = Address::from(0x8900c5bec4ca97d4febf9ceb4754a60d782abbf3cd815836c1872116f203f861);

I tried to fork this contract, but ran into one stuff: my addresses from “forc-wallet” and from fuel, wallet look like that fuel1lw8hf2fvwmmwwlkn3z2q8854lwshud4dazp6487wn6jkmuz0jfwqce9v0j.
How to convert my address to the 0x... type?

2 Likes

Great question! The Fuels Rust SDK and TypeScript SDK both have functions to convert between a Bech32 Address (starts with ‘fuel’), and a B256 address (starts with “0x”):

Rust SDK: Bech32 - The Fuel Rust SDK

TypeScript SDK: Bech32 | Fuels-ts

2 Likes

@sarah Thanks a lot!!!

1 Like

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