ETH Wallet address conversion

How are the wallet addresses associated with an ETH address determined?

I see that an ETH address has 42 chars and a fuel hex address has 66.

Also, Is the wallet an Identity::Address or an Identity::ContractId under the hood?

I would love to use:

 Identity::Address(Address::from_str("0x123...42").unwrap())

But this only works when the address it is a fuel address

If you have an evm address, then our connectors generates a predicate corresponding to that evm address. this way, you can have a predicate for an evm address and this predicate will use the signature of the evm wallet to make txns.

Fuel uses a 32-byte address format, and this is why a Fuel hex address is longer (66 characters) compared to an ETH address (42 characters).

Fuel addresses can be converted between different formats using the Fuel SDK. For example, you can convert between Bech32 and hex formats. Here’s how you can convert a Bech32 address to a hex format:

// #import { Address };
const bech32 = 'fuel1d5cfwekq78r0zq73g7eg0747etkaxxltrqx5tncm7lvg89awe3hswhqjhs';
const addressInstance = Address.fromDynamicInput(bech32);
const b256 = addressInstance.toB256();
// 0x6d309766c0f1c6f103d147b287fabecaedd31beb180d45cf1bf7d88397aecc6f

Identity Type

In Fuel, the Identity type can be either an Identity::Address or an Identity::ContractId. When dealing with wallet addresses, they are typically represented as Identity::Address.

But lets say I have a bunch of EVM addresses, I need to know how to send them funds on fuel. With only their EVM address is there a function to generate their Fuel address which uses the predicate?

Hey @diyahir We don’t have this logic in the SDK and you’d have to use the connectors package for it.

You can find here how we’re getting the predicate addresses associated with some EVM addresses. This seems like the thing you need. In the end, it boils down to a call to this method. Lmk if you are looking for something else

I wrote this script to perform the action here:
Can you validate it? I want to make sure I get it right, currently to validate I have been connecting to a wallet on a fuel dapp using it and just spot checking that it spits out the right address

You can run it by using the following command

npm run generate-predicate-addresses

and it outputs to generated/predicate-addresses.json

This is the branch:

I have checked your code that generates the predicate addresses for the EVM address, and that looks good to me.

Why is the mainnet and testnet generated address with evm predicate derived address different?

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