Account Structure
On ENI, accounts are represented by two address formats:
ENI native Bech32 (
eni...
)EVM-compatible Hex (
0x...
)
Both addresses for a single account are derived from the same public key.Because eni is fully compatible with Ethereum and the Ethereum ecosystem is prosperous, it is recommended to use an eth address.
Deriving Addresses from Public Key
ENI Address Derivation
ENI native addresses are derived from the public key using the following steps:
Hash the public key using the
Keccak256
algorithm.Extract the first 20 bytes of the resulting hash.
Encode the extracted bytes in Bech32 format with the "eni" prefix.
Example implementation:
import { bech32 } from 'bech32';
import { keccak256 } from 'ethereumjs-util';
export function deriveEniAddress(publicKey: Buffer): string {
const hash = keccak256(publicKey);
const words = bech32.toWords(hash.slice(0, 20));
return bech32.encode('eni', words);
}
EVM Address Derivation
The EVM-compatible address is derived as follows:
Hash the public key using the
Keccak256
algorithm.Extract the last 20 bytes of the resulting hash.
Prefix the extracted bytes with
0x
to obtain the EVM address.
Example implementation:
import { keccak256 } from 'ethereumjs-util';
export function deriveEVMAddress(publicKey: Buffer): string {
const hash = keccak256(publicKey);
return `0x${hash.slice(-20).toString('hex')}`;
}
Summary
Public Key Hash:Both address derivations rely on the Keccak256 hashing algorithm.
ENI Address:
Extracts the first 20 bytes of the hash.
Encodes these bytes into Bech32 format with the "eni" prefix.
EVM Address:
Extracts the last 20 bytes of the hash.
Formats these bytes as Hex with the "0x" prefix.
Why This Works
Keccak256
hashing ensures that the process of deriving both address formats from the same public key is consistent and verifiable.
This mechanism enables a single account to remain compatible in both ENI native and EVM environments.
Next Steps
For a detailed technical explanation on how to perform account linking, please refer to the Wallet Linking section.
Last updated