Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zilliqa: bech32 address standard #2311

Closed
fedor-ivn opened this issue Oct 21, 2024 · 4 comments · Fixed by #2351
Closed

Zilliqa: bech32 address standard #2311

fedor-ivn opened this issue Oct 21, 2024 · 4 comments · Fixed by #2351
Assignees
Labels
enhancement New feature or request v1.36.0 Release v1.36.0

Comments

@fedor-ivn
Copy link

fedor-ivn commented Oct 21, 2024

Motivation

Although the Zilliqa protocol utilizes 20-byte base16 checksum addresses on the backend, bech32 addresses are widely adopted in the Zilliqa ecosystem by wallets and SDKs. As a result, bech32 addresses are only visible to end users.

For reference, ViewBlock explorer for Zilliqa supports bech32 addresses. See this example. We should also have similar support for bech32 addresses in Blockscout.

UI customizations

For the MVP, we should add support to convert EVM hex addresses (base16) to bech32 format. This change will affect every component that displays raw EVM addresses (0x...). In my vision, the 0x... address components can become clickable, triggering the conversion to bech32 format when clicked. For example 0x87df0306F147e752805261156d5a00d912786B18 should become zil1qzra7qcx79r7w55q2fs32m26qrv3y7rtrk8hjl7 when clicked and vice versa.

Implementation details

To handle the conversion, we can use the bech32 npm package. As I found out, It’s a widely adopted library for this task.

Zilliqa bech32 address structure

Human-readable prefix Separator bech32 formatted address Checksum
Example 1 zil 1 02n74869xnvdwq3yh8p0k9jjgtejruft 268tg8
Example 2 zil 1 48fy8yjxn6jf5w36kqc7x73qd3ufuu24 a4u8t9
Example 3 zil 1 fdv7u7rll9epgcqv9xxh9lhwq427nsql 58qcs9
  • The prefix for the Zilliqa mainnet is zil, and for the developer testnet, it’s also zil.
  • The last six characters form a checksum, which contains no additional information.

For further details, refer to the Zilliqa Address Standard (Bech32) documentation here.

Test Cases

base16 Address bech32 Address
0x7Aa7eA9f4534d8D70224b9c2FB165242F321F12b zil102n74869xnvdwq3yh8p0k9jjgtejruft268tg8
0x1d19918a737306218b5cbb3241fcdcbd998c3a72 zil1r5verznnwvrzrz6uhveyrlxuhkvccwnju4aehf

To create additional test cases, you can use this online converter, which also is open-source and available on GitHub.

Further bech32 support

It would be cool if we extend this feature to handle bech32 addresses in URLs, allowing links like https://zilliqa.blockscout.com/address/zil102n74869xnvdwq3yh8p0k9jjgtejruft268tg8 to redirect to the correct address page.

@fedor-ivn fedor-ivn added the need design For issues that wait for design updates label Oct 21, 2024
@fedor-ivn
Copy link
Author

I think it might be useful to make the bech32 prefix configurable through some env, leaving zil as a default value.

@fedor-ivn
Copy link
Author

Nevertheless, the default format should be base16

@fedor-ivn fedor-ivn added enhancement New feature or request and removed need design For issues that wait for design updates labels Oct 28, 2024
@fedor-ivn
Copy link
Author

The layouts are prepared. Check it out here:

https://www.figma.com/design/3AREwPxLneFINGD2jt7RGS/Zilliqa%3A-bech32-address-standard?node-id=1-3374&t=ldnkRpzQRsiuiUY8-1

@tom2drum tom2drum self-assigned this Oct 31, 2024
@tom2drum
Copy link
Collaborator

tom2drum commented Nov 1, 2024

New frontend ENV variables example (for Zilliqa chain):

NEXT_PUBLIC_VIEWS_ADDRESS_FORMAT=['bech32','base16']
NEXT_PUBLIC_VIEWS_ADDRESS_BECH_32_PREFIX=zil

@github-actions github-actions bot added pre-release Tasks in pre-release right now v1.36.0 Release v1.36.0 and removed pre-release Tasks in pre-release right now labels Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v1.36.0 Release v1.36.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants