AccountKit Class

The AccountKit class provided by the Account Kit is a factory class that facilitates the creation of Account instances.

Creation

When using the AccountKit factory class within a web application, the developer will first need to instantiate it. Here is a basic example of how to do so:

import { AccountKit } from "@wharfkit/account"
import { Chains } from "@wharfkit/common"

const accountKit = new AccountKit(Chains.EOS)

Optionally, a Contract and/or an APIClient instance can be passed to the AccountKit factory class constructor:

import { AccountKit } from "@wharfkit/account"
import { APIClient } from "@wharfkit/antelope"
import { Chains } from "@wharfkit/common"
import { ContractKit } from "@wharfkit/contract"

const client = new APIClient({ url: "https://jungle4.greymass.com" })

const contractKit = new ContractKit({
  client,
})

const contract = await contractKit.load("contractname")

const accountKit = new AccountKit(Chains.EOS, {
  client,
  contract,
})

Arguments

The AccountKit constructor expects one parameter:

Options

A second optional parameter can be passed to the AccountKit constructor with the following options:

  • client: An API client instance that will be used to fetch account data. If not provided, a client will be created using the default configuration for the specified chain.
  • contract: A Contract instance that will be used by all Account instances created by the factory. If not provided, the system contract will be used.

Usage

Load Method

Once an AccountKit instance is obtained, the load method can be used to obtain an Account instance for a specific Antelope blockchain account. Here is an example of how to do so:

const account = await accountKit.load("teamgreymass")

Arguments

The load method accepts a single parameter:

  • accountName: The name of the account to load.

Return Value

The load method returns an Account instance.