Hethers
Search
K

Accounts

Helper utilities for deriving account data from addresses or transactions.

Data Types

Account = {
shard: bigint
realm: bigint
num: bigint
}
AccountLike = Account | string

Functions

hethers.utils.getAddressFromAccount(accountLike: AccountLike) => string

Returns a hex representation of the provided account id.
hethers.utils.getAddressFromAccount('0.0.1')
// 0x0000000000000000000000000000000000000001

hethers.utils.getAccountFromAddress(address: string) => Account

Returns an Account object from the provided ECDSA hash.
hethers.utils.getAccountFromAddress('0x0000000000000000000000000000000000000001')
// { shard: 0n, realm: 0n, num: 1n }

hethers.utils.parseAccount(account: string) => Account

Returns an Account object from the provided string. Accepts either an account id or ECDSA hash.
hethers.utils.parseAccount('0x0000000000000000000000000000000000000001')
// { shard: 0n, realm: 0n, num: 1n }
hethers.utils.parseAccount('0.0.1')
// { shard: 0n, realm: 0n, num: 1n }

hethers.utils.asAccountString(accountLike: AccountLike) => string

Converts the provided AccountLike data to an AccountId.
hethers.utils.asAccountString('0x0000000000000000000000000000000000000001')
// '0.0.1'

hethers.utils.getAccountFromTransactionId( transactionId: string) => string

Accepts a valid TransactionId and extracts the accountId of the transation sender. Throws an INVALID_ARGUMENT error If an invalid transactionId is provided.
hethers.utils.getAccountFromTransactionId("0.0.99999999@9999999999-999999999")
// 0.0.99999999
Last modified 1yr ago