Skip to main content
Version: 6.11.0

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:49


address​

• Abstract address: string

Defined in​

src/contract/interface.ts:51


providerOrAccount​

• Abstract providerOrAccount: ProviderInterface | AccountInterface

Defined in​

src/contract/interface.ts:53


deployTransactionHash​

• Optional Abstract deployTransactionHash: string

Defined in​

src/contract/interface.ts:55


functions​

• Readonly functions: Object

Index signature​

â–ª [name: string]: AsyncContractFunction

Defined in​

src/contract/interface.ts:57


callStatic​

• Readonly callStatic: Object

Index signature​

â–ª [name: string]: AsyncContractFunction

Defined in​

src/contract/interface.ts:59


populateTransaction​

• Readonly populateTransaction: Object

Index signature​

â–ª [name: string]: ContractFunction

Defined in​

src/contract/interface.ts:61


estimateFee​

• Readonly estimateFee: Object

Index signature​

â–ª [name: string]: ContractFunction

Defined in​

src/contract/interface.ts:63

Methods​

attach​

â–¸ attach(address): void

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

Parameters​

NameTypeDescription
addressstringaddress of the contract

Returns​

void

Defined in​

src/contract/interface.ts:72


connect​

â–¸ connect(providerOrAccount): void

Attaches to new Provider or Account

Parameters​

NameTypeDescription
providerOrAccountProviderInterface | AccountInterfacenew Provider or Account to attach to

Returns​

void

Defined in​

src/contract/interface.ts:79


deployed​

â–¸ deployed(): Promise<ContractInterface>

Resolves when contract is deployed on the network or when no deployment transaction is found

Returns​

Promise<ContractInterface>

Promise that resolves when contract is deployed on the network or when no deployment transaction is found

Throws

When deployment fails

Defined in​

src/contract/interface.ts:87


call​

â–¸ call(method, args?, options?): Promise<Result>

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<Result>

Result of the call as an array with key value pars

Defined in​

src/contract/interface.ts:97


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?InvokeOptions

Returns​

Promise<{ transaction_hash: string }>

Add Transaction Response

Defined in​

src/contract/interface.ts:111


estimate​

â–¸ estimate(method, args?, options?): Promise<EstimateFeeResponse>

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<EstimateFeeResponse>

Defined in​

src/contract/interface.ts:124


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:139


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:147


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:158


getVersion​

â–¸ getVersion(): Promise<ContractVersion>

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

Returns​

Promise<ContractVersion>

Defined in​

src/contract/interface.ts:163


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:171