Hethers
  • Documentation
  • Getting Started
  • Application Programming Interface
    • Providers
      • Provider
        • Accounts Methods
        • Logs Methods
        • Network Status Methods
        • Transactions Methods
        • Event Emitter Methods
        • Base Provider
        • HederaProvider
      • Types
    • Contract Interaction
      • Contract
      • ContractFactory
      • Example: ERC-20 Contract
    • Utilities
      • Accounts
      • Addresses
      • Application Binary Interface
        • AbiCoder
        • ABI Formats
        • Fragments
        • Interface
      • BigNumber
      • Byte Manipulation
      • Constants
      • Display Logic and Input
      • Encoding Utilities
      • FixedNumber
      • Hashing Algorithms
      • HD Wallet
      • Logging
      • Property Utilities
      • Signing Key
      • Strings
      • Transactions
      • Web Utilities
      • Wordlists
    • Signers
  • Contributing
  • Other Resources
Powered by GitBook
On this page
  • Data Types
  • Functions
  1. Application Programming Interface
  2. Utilities

Accounts

PreviousUtilitiesNextAddresses

Last updated 3 years ago

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: ) => string

Returns a hex representation of the provided account id.

hethers.utils.getAddressFromAccount('0.0.1')
// 0x0000000000000000000000000000000000000001

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

hethers.utils.getAccountFromAddress('0x0000000000000000000000000000000000000001')
// { shard: 0n, realm: 0n, num: 1n }

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('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

Returns an object from the provided ECDSA hash.

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

Returns an object from the provided string. Accepts either an account id or ECDSA hash.

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

Converts the provided data to an AccountId.

AccountLike
Account
Account
Account
Account
AccountLike
AccountLike