UNPKG

@xpla/xpla

Version:

<p align="center"> <img src="https://user-images.githubusercontent.com/545047/188804067-28e67e5e-0214-4449-ab04-2e0c564a6885.svg" width="80"> </p>

19 lines (18 loc) 647 B
import { AccountBase } from '@interchainjs/types/account'; import { Key } from '@interchainjs/utils'; import { keccak_256 } from '@noble/hashes/sha3'; /** * Account for ethermint chain. */ export class EthAccount extends AccountBase { /** * Create eth address by pubkey. */ getAddressByPubKey() { const uncompressedPubKey = this.auth.getPublicKey(false); const pubkeyHex = uncompressedPubKey.toHex().substring(2); const pubkeyHexKey = Key.fromHex(pubkeyHex); const addressBytes = keccak_256(pubkeyHexKey.value).subarray(-20); return Key.from(addressBytes).toBech32(this.prefix); } }