Understanding OKTC Accounts and Address Formats

·

This guide explains the built-in accounts system of the OKTC blockchain, detailing its custom account types, address formats, and practical usage.

Prerequisite Readings

To fully grasp the OKTC accounts system, familiarity with the following concepts is beneficial:

The OKTC Account Model

OKTC implements a custom Account type that utilizes Ethereum's ECDSA secp256k1 curve for cryptographic keys. This design aligns with the EIP84 standard and supports full BIP44 derivation paths. The root Hierarchical Deterministic (HD) path for all OKTC-based accounts is m/44'/60'/0'/0.

Addresses and Public Keys

The OKTC network features three primary types of addresses and public keys by default:

  1. Accounts: These identify users, such as the sender of a transaction. They are derived using the eth_secp256k1 curve.
  2. Validator Operators: These identify the operators of network validators. They are also derived using the eth_secp256k1 curve.
  3. Consensus Nodes: These identify the validator nodes that actively participate in the network's consensus mechanism. They are derived using the ed25519 curve.

The following table summarizes the key differences:

TypeAddress bech32 PrefixPubkey bech32 PrefixCurveAddress byte lengthPubkey byte length
Accountsexexpubeth_secp256k12033 (compressed)
Validator Operatorexvaloperexvaloperpubeth_secp256k12033 (compressed)
Consensus Nodesexvalconsexvalconspubed255192032

Address Formats for Client Compatibility

An OKTCAccount can be represented in two distinct formats to ensure compatibility across different tools and ecosystems.

Examples:

You can query an account address using the OKTC CLI. Note that the native Cosmos SDK Keyring (e.g., exchaincli keys) only outputs addresses in Bech32 format. To retrieve the Ethereum hex address, you must use the JSON-RPC oktc_accounts endpoint.

The Relationship Between 'ex' and '0x' Addresses

A single mnemonic phrase on OKTC generates two corresponding address formats:

These two addresses are different representations of the same underlying account. They share the same balance and are controlled by the same private keys. Importing the mnemonic into MetaMask will reveal the 0x address, while using exchaincli or checking a DEX web/mobile client will display the ex address.

How to Use Different Address Formats

The appropriate address format depends on the tool you are using:

👉 Explore more strategies for managing cross-chain addresses

Important Note: When sending funds, you must use the correct address format for the recipient's context. Transfers must be sent to ex addresses from ex addresses and to 0x addresses from 0x addresses. Cross-format transfers are not possible.

Converting Between Address Formats

Since both address formats originate from the same mnemonic, they are mathematically interoperable and can be converted from one to the other.

You can programmatically convert between these formats using helper methods available in the official OKTC SDKs, such as convertAddressFromHexToBech32 and convertAddressFromBech32ToHex.

Frequently Asked Questions

What is the difference between an 'ex' address and a '0x' address?
They are two different representations of the same account on the OKTC blockchain. The 'ex' address (Bech32) is used for native Cosmos-SDK operations, while the '0x' address (Hex) is used for Ethereum tooling compatibility. Both are derived from the same private key and control the same funds.

Can I send funds from my 'ex' address to a '0x' address?
No, you cannot send funds directly between different address formats. You must send funds to an address of the same format. The recipient's wallet will automatically reflect the balance on both address formats since they represent the same account.

Which address should I use to stake or vote on the network?
You must use the native Bech32 format address (starting with ex) for all chain-specific operations like staking, governance voting, and using the CLI. These functionalities are built on the Cosmos SDK and require the native address format.

How do I find my '0x' address if I only have my 'ex' address?
You can use the conversion utilities provided in the official OKTC JavaScript or Java SDKs. By inputting your ex address into the convertAddressFromBech32ToHex method, you will receive the corresponding 0x address.

Why does OKTC support two address formats?
The dual-format system provides the best of both worlds: the robust staking and governance features of the Cosmos ecosystem (via Bech32) and full compatibility with the vast ecosystem of Ethereum wallets, dApps, and tools (via Hex).

Is my balance affected by the address format I use?
No, your balance is attached to your account, not to a specific address format. Whether you view your account through a tool that shows the ex address or one that shows the 0x address, you are looking at the same balance for the same account.