Skip to main content
Version: Next

Class: ContractInterface

Implemented by

Indexable

[key: string]: AsyncContractFunction | any

Constructors

constructor

new ContractInterface(): ContractInterface

Returns

ContractInterface

Properties

abi

Abstract abi: Abi

Defined in

src/contract/interface.ts:48


address

Abstract address: string

Defined in

src/contract/interface.ts:50


providerOrAccount

Abstract providerOrAccount: ProviderOrAccount

Defined in

src/contract/interface.ts:52


classHash

Optional Abstract classHash: string

Defined in

src/contract/interface.ts:54


functions

Readonly functions: Object

Index signature

[name: string]: AsyncContractFunction

Defined in

src/contract/interface.ts:56


callStatic

Readonly callStatic: Object

Index signature

[name: string]: AsyncContractFunction

Defined in

src/contract/interface.ts:58


populateTransaction

Readonly populateTransaction: Object

Index signature

[name: string]: ContractFunction

Defined in

src/contract/interface.ts:60


estimateFee

Readonly estimateFee: Object

Index signature

[name: string]: ContractFunction

Defined in

src/contract/interface.ts:62

Methods

attach

attach(address, abi?): void

Saves the address of the contract deployed on network that will be used for interaction

Parameters

NameTypeDescription
addressstringaddress of the contract
abi?Abioptional new abi to use with the contract

Returns

void

Defined in

src/contract/interface.ts:72


isDeployed

isDeployed(): Promise<ContractInterface>

Verifies that the contract is deployed at the configured address

Returns

Promise<ContractInterface>

Promise that resolves when contract is confirmed to exist at the address

Throws

Error if the contract is not deployed at the address

Defined in

src/contract/interface.ts:80


call

call(method, args?, options?): Promise<CallResult>

Calls a method on a contract

Parameters

NameTypeDescription
methodstringname of the method
args?ArgsOrCalldataArray of the arguments for the call
options?CallOptionsoptional blockIdentifier

Returns

Promise<CallResult>

Result of the call as an array with key value pars

Defined in

src/contract/interface.ts:90


invoke

invoke(method, args?, options?): Promise<{ transaction_hash: string }>

Invokes a method on a contract

Parameters

NameTypeDescription
methodstringname of the method
args?ArgsOrCalldataArray of the arguments for the invoke or Calldata
options?ExecuteOptions

Returns

Promise<{ transaction_hash: string }>

Add Transaction Response

Defined in

src/contract/interface.ts:104


estimate

estimate(method, args?, options?): Promise<EstimateFeeResponseOverhead>

Estimates a method on a contract

Parameters

NameTypeDescription
methodstringname of the method
args?ArgsOrCalldataArray of the arguments for the call or Calldata
options?Objectoptional blockIdentifier
options.blockIdentifier?BlockIdentifier-

Returns

Promise<EstimateFeeResponseOverhead>

Defined in

src/contract/interface.ts:117


populate

populate(method, args?): Invocation

Calls a method on a contract

Parameters

NameTypeDescription
methodstringname of the method
args?ArgsOrCalldataArray of the arguments for the call or Calldata

Returns

Invocation

Invocation object

Defined in

src/contract/interface.ts:132


parseEvents

parseEvents(receipt): ParsedEvents

Parse contract events of a GetTransactionReceiptResponse received from waitForTransaction. Based on contract's abi

Parameters

NameTypeDescription
receiptGetTransactionReceiptResponsetransaction receipt

Returns

ParsedEvents

Events parsed

Defined in

src/contract/interface.ts:140


isCairo1

isCairo1(): boolean

tells if the contract comes from a Cairo 1 contract

Returns

boolean

TRUE if the contract comes from a Cairo1 contract

Example

const isCairo1: boolean = myContract.isCairo1();

Defined in

src/contract/interface.ts:151


getVersion

getVersion(): Promise<ContractVersion>

Retrieves the version of the contract (cairo version & compiler version)

Returns

Promise<ContractVersion>

Defined in

src/contract/interface.ts:156


typedv2

typedv2<TAbi>(tAbi): TypedContractV2<TAbi>

Returns a typed instance of ContractV2 based on the supplied ABI.

Type parameters

NameType
TAbiextends readonly (AbiImpl | AbiFunction | AbiInterface | AbiConstructor | AbiEvent | AbiStruct | AbiEnum)[]

Parameters

NameTypeDescription
tAbiTAbiThe ABI (Abstract Binary Interface) of the ContractV2.

Returns

TypedContractV2<TAbi>

  • A typed instance of ContractV2.

Defined in

src/contract/interface.ts:164