Contract

A Contract class instance represents a specific Antelope smart contract. It makes several methods available to retrieve contract data, as well as generating contract actions that can be executed using the SessionKit transact method.

Creation

In most cases, Contract instances will be created by the ContractKit load method or accessed directly from code generated using the command line application. However, they can also be created manually:

import { Contract } from "@wharfkit/contract"
import { APIClient } from "@wharfkit/antelope"

import abi from "./eosio-abi.json" // ABI for the eosio.token contract

const contractArgs = {
  abi,
  account: "eosio.token",
  client: new APIClient("https://jungle4.greymass.com"),
}

const contract = new Contract(contractArgs)

Arguments

The only parameter passed to the Contract class constructor is an object containing the following configuration data:

  • abi: The ABI definition for the smart contract.
  • account: The name of the account that the contract is deployed to.
  • client: An instance of an APIClient that will be used to fetch blockchain data.

Usage

Once a Contract instance is created, methods and read-only properties are available.

Methods

  • action: Generates an Action instance that can be passed to the SessionKit transact method.
  • table: Generates a specific Table instance from the Contract.

Properties

  • abi: The ABI of the contract.
  • account: The name of the account that the contract is deployed to.
  • actionNames: An array with the names of actions that exist on the contract.
  • tableNames: An array with the names of tables that exist on the contract.