ConfluxPortal base32 Address Format Conversion Introduction

Notice:

  1. ConfluxPortal is planned to be upgraded to v0.6.x in the extension store of Chrome and Firefox between 11am to 1 pm (GMT+8) on March 9th, 2021.
  2. Download link of v0.6.0 (since it is beta version, the version number and file name are still 0.5.11):

The influence of v0.6.x on DApps

  • When calling ConfluxPortal API window.conflux.sendAsync directly or calling ConfluxPortal API window.confluxJS.xxx through SDK, the returned addresses will be in base32 format.
  • The fullnode connecting the Portal mainnet/testnet will be upgraded to v1.1.0 or above, which does not support hex40 addresses (the RPC address is changed, the corresponding fullnode is not upgraded directly).
  • When users change the network, two events will be released: networkChanged and accountsChanged. The accountsChanged event will return with the addresses of the new network.
  • The inbuilt js-conflux-sdk of Portal will be upgraded to v1.5.11.
  • When calling cfx_signTypedData_v4, it is suggested to use base32 addresses in the signature.

Conversion Documents

  1. You can check whether the Portal is the latest version by checking the address format it returns (conflux.enable event and accountsChanged event).
  2. There are two adaptation methods. When calling v0.6.x of Portal API, the input Conflux addresses should be in base32 format, and the output Conflux network addresses of Portal should also be in base32 format.
    • The first conversion method supports both Portal v0.5.x and v0.6.x.
      • In this way, DApp developers need to check the version of Portal, and send addresses in different formats to Portal according to the different versions, and resolve the returned addresses.
      • The principle is: if Portal returns hex40 addresses, hex40 addresses should be sent to Portal, and the same, if Portal returns base32 addresses, base32 addresses should be sent to it. If DApp directly connects to the upgraded fullnode, it needs to send base32 addresses.
      • In this method, DApps will not be affected by Portal upgrade. DApps can be upgraded to the version adapted to base32 address in advance.
    • The second conversion method only supports Portal v0.6.x. DApp should upgrade right after the upgrade of Portal. If user’s Portal is an old version, the user operation will be blocked, and the user will be noticed to upgrade Portal to the latest version.
      • In this method, DApps will be affected by Portal upgrade and can only be upgraded after Portal is v0.6.x.
  3. You can refer to this demo to adapt the new address format for DApps.
    • The demo sopports Portal of both v0.5.x and v0.6.x (method a).
    • The demo includes an islikebase32address function to check whether the address is base32 (note that this function can not be used to determine whether the address is legal). You can use this function to determine whether the address given by Portal is in base32 format.
    • Treat the addresses in the DApp according to the check result.