Skip to content

ss58toH160 incorrect #7

@Imdavyking

Description

@Imdavyking

the result should have a keccak256 bytes of the public key

export function ss58ToH160(accountSS58Address: string): string {
// Decode the SS58 address to a Uint8Array public key
const publicKey = decodeAddress(accountSS58Address);

// Step 2: Hash with keccak256
const hashed = keccak256(publicKey); // hex string (0x-prefixed, 64 chars)

// Step 3: Take last 20 bytes (40 hex characters)
const ethAddress = "0x" + hashed.slice(-40); // Ethereum H160 address

console.log("Ethereum-style address:", ethAddress);
return ethAddress;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions