Inconsistent bech32/hex address format in API calls

I’m using the API to get transaction data from blocks. I use the hmyv2_getBlockByNumber to get top-level transaction data and then hmy_getLogs to LogEvents.

In responses from hmyv2_getBlockByNumber the to/from addresses are in the bech32 format (one...), but all addresses in the logs are hex (0x...).

Will this always be the case or does Harmony plan to convert all addresses to bech32 format?

1 Like

Not sure what the plans for the future are but I wrote a docker service to convert addresses.

The code for the conversion is here but you will also require the module included or just boot up the service and call via API…

1 Like

Thank you. Converting it is no problem, I’m already doing that with this npm package. I’m just wondering if there will be breaking changes in the future. I don’t quite understand why top level addresses in the from/to of hmyv2_getBlockByNumber are bech32 but everything else is hex. We just convert to hex for our own sanity/ease :slight_smile:

1 Like

I was just about to post the js version :laughing: :rofl:

I’m the same, don’t care what format but i generally stick to one or the other.

It would be nice to have some consistency api wise.

@giv @rongjian do we have any plans to align this in the future?

1 Like

I haven’t tested this myself. But you can check if eth_/hmy_/hmyv2_ methods give different results. AFAIK that’s what they are intended for