Skip to main content

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:


_10
import * as sdk from "@onflow/sdk"
_10
_10
sdk.account(address, options, opts)

Or import directly the specific function:


_10
import { account } from "@onflow/sdk"
_10
_10
account(address, options, opts)

Usage


_29
import * as fcl from "@onflow/fcl";
_29
_29
// Get account from latest block height
_29
const account = await fcl.account("0x1d007d755706c469");
_29
console.log("Address:", account.address);
_29
console.log("Balance:", account.balance);
_29
console.log("Keys:", account.keys);
_29
console.log("Contracts:", Object.keys(account.contracts));
_29
_29
// Get account at a specific block height
_29
const historicalAccount = await fcl.account("0x1d007d755706c469", {
_29
height: 12345
_29
});
_29
_29
// Get account at a specific block ID
_29
const accountAtBlock = await fcl.account("0x1d007d755706c469", {
_29
id: "9dda5f281897389b99f103a1c6b180eec9dac870de846449a302103ce38453f3"
_29
});
_29
_29
// Get account from sealed block
_29
const sealedAccount = await fcl.account("0x1d007d755706c469", {
_29
isSealed: true
_29
});
_29
_29
// Alternative using builder pattern
_29
fcl.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

_10
interface AccountQueryOptions {
_10
height?: number
_10
id?: string
_10
isSealed?: boolean
_10
}

opts (optional)

  • Type: object
  • Description: Optional parameters

Returns

Promise<Account>