When the shard (S
) and realm (R
) are both 0
,
only need to convert the number (N
)
from decimal to hexadecimal,
and pad the left with leading zeroes.
This is also known as the long-zero address,
due to a large number of leading zeroes.
- Example Hedera-native address (
S.R.N
) format:0.0.12345
- Example EVM address (
0x...
) format:0x0000000000000000000000000000000000003039
However, if shard (S
) and realm (R
) are non-zero,
the conversion process is sliughtly more complex,
and each component needs to be
converted and padded separately,
then concatenated together.
- Example Hedera-native address (
S.R.N
) format:17.2049.12345
- Example EVM address (
0x...
) format:0x0000001100000000000008010000000000003039
The convert.js
file in this directory demonstrates how to do the above.
- It makes use of
EntityIdHelper
from hedera-sdk-js to perform the above conversions EntityIdHelper.fromString
splitsS.R.N
the string into 3 numbersEntityIdHelper.toSolidityAddress
converts, pads, and concatenates the 3 numbers, resulting in the final output.
Try it out:
node ./convert.js
This should produce the following output:
'0.0.12345' --> '0000000000000000000000000000000000003039'
'17.2049.12345' --> '0000001100000000000008010000000000003039'