account
Retrieve any account from Flow network's latest block or from a specified block height.
Account address is a unique account identifier. Be mindful about the '0x' prefix, you should use the prefix as a default representation but be careful and safely handle user inputs without the prefix.
An account includes the following data:
- Address: the account address.
- Balance: balance of the account.
- Contracts: list of contracts deployed to the account.
- Keys: list of keys associated with the account.
Import
You can import the entire package and access the function:
_10import * as sdk from "@onflow/sdk"_10_10sdk.account(address, options, opts)
Or import directly the specific function:
_10import { account } from "@onflow/sdk"_10_10account(address, options, opts)
Usage
_29import * as fcl from "@onflow/fcl";_29_29// Get account from latest block height_29const account = await fcl.account("0x1d007d755706c469");_29console.log("Address:", account.address);_29console.log("Balance:", account.balance);_29console.log("Keys:", account.keys);_29console.log("Contracts:", Object.keys(account.contracts));_29_29// Get account at a specific block height_29const historicalAccount = await fcl.account("0x1d007d755706c469", {_29 height: 12345_29});_29_29// Get account at a specific block ID_29const accountAtBlock = await fcl.account("0x1d007d755706c469", {_29 id: "9dda5f281897389b99f103a1c6b180eec9dac870de846449a302103ce38453f3"_29});_29_29// Get account from sealed block_29const sealedAccount = await fcl.account("0x1d007d755706c469", {_29 isSealed: true_29});_29_29// Alternative using builder pattern_29fcl.send([_29 fcl.getAccount("0x1d007d755706c469"),_29 fcl.atBlockHeight(123)_29]).then(fcl.decode);
Parameters
address
- Type:
string
- Description: Address of the account
options
(optional)
- Type:
AccountQueryOptions
_10interface AccountQueryOptions {_10 height?: number_10 id?: string_10 isSealed?: boolean_10}
opts
(optional)
- Type:
object
- Description: Optional parameters