hedera-sdk-java icon indicating copy to clipboard operation
hedera-sdk-java copied to clipboard

toSolidityAddress - Does not work for correctly for “native” EVM addresses

Open se7enarianelabs opened this issue 1 year ago • 2 comments

Description

When you have a Hedera account, such as 0.0.104225, that possesses a 'native' EVM address, utilizing the toSolidityAddress method on such an AccountId results in an incorrect solidity address. This discrepancy can potentially introduce bugs in the services that make use of it. Currently, it is necessary to retrieve the value of the EVM address from the mirror node to handle all accounts without relying on conditional statements. In our opinion, an SDK method should internally handle different cases, as the current approach may introduce bugs in the services that rely on it

Steps to reproduce

Run this function:

java
/**
 * Extract the Solidity address.
 *
 * @return the Solidity address as a string
 */
public String toSolidityAddress()

on this account: 0.0.104225

Additional context

Method: AccountId.fromString("0.0.104225").toSolidityAddress(); Expected: 0x87a8a5c124577bcca68ba44dd12c76d3e427805a Actual: 0x0000000000000000000000000000000000019721

Hedera network

mainnet, testnet, previewnet

Version

v2.18.2

Operating system

None

se7enarianelabs avatar Dec 15 '23 15:12 se7enarianelabs