Skip to main content
Version: 5.24.3

Class: Contract

Implements​

Indexable​

β–ͺ [key: string]: AsyncContractFunction | any

Constructors​

constructor​

β€’ new Contract(abi, address, providerOrAccount?)

Contract class to handle contract methods

Parameters​

NameTypeDefault valueDescription
abiAbiundefinedAbi of the contract object
addressstringundefined(optional) - address to connect to
providerOrAccountProviderInterface | AccountInterfacedefaultProvider(optional) - Provider or Account to attach to

Defined in​

src/contract/default.ts:148

Properties​

abi​

β€’ abi: Abi

Implementation of​

ContractInterface.abi

Defined in​

src/contract/default.ts:117


address​

β€’ address: string

Implementation of​

ContractInterface.address

Defined in​

src/contract/default.ts:119


providerOrAccount​

β€’ providerOrAccount: ProviderInterface | AccountInterface

Implementation of​

ContractInterface.providerOrAccount

Defined in​

src/contract/default.ts:121


deployTransactionHash​

β€’ Optional deployTransactionHash: string

Implementation of​

ContractInterface.deployTransactionHash

Defined in​

src/contract/default.ts:123


structs​

β€’ Protected Readonly structs: Object

Index signature​

β–ͺ [name: string]: StructAbi

Defined in​

src/contract/default.ts:125


events​

β€’ Protected Readonly events: AbiEvents

Defined in​

src/contract/default.ts:127


functions​

β€’ Readonly functions: Object

Index signature​

β–ͺ [name: string]: AsyncContractFunction

Implementation of​

ContractInterface.functions

Defined in​

src/contract/default.ts:129


callStatic​

β€’ Readonly callStatic: Object

Index signature​

β–ͺ [name: string]: AsyncContractFunction

Implementation of​

ContractInterface.callStatic

Defined in​

src/contract/default.ts:131


populateTransaction​

β€’ Readonly populateTransaction: Object

Index signature​

β–ͺ [name: string]: ContractFunction

Implementation of​

ContractInterface.populateTransaction

Defined in​

src/contract/default.ts:133


estimateFee​

β€’ Readonly estimateFee: Object

Index signature​

β–ͺ [name: string]: ContractFunction

Implementation of​

ContractInterface.estimateFee

Defined in​

src/contract/default.ts:135


callData​

β€’ Private callData: CallData

Defined in​

src/contract/default.ts:139

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

Implementation of​

ContractInterface.attach

Defined in​

src/contract/default.ts:204


connect​

β–Έ connect(providerOrAccount): void

Attaches to new Provider or Account

Parameters​

NameTypeDescription
providerOrAccountProviderInterface | AccountInterfacenew Provider or Account to attach to

Returns​

void

Implementation of​

ContractInterface.connect

Defined in​

src/contract/default.ts:208


deployed​

β–Έ deployed(): Promise<Contract>

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

Throws

When deployment fails

Returns​

Promise<Contract>

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

Implementation of​

ContractInterface.deployed

Defined in​

src/contract/default.ts:212


call​

β–Έ call(method, args?, Β«destructuredΒ»?): Promise<Result>

Calls a method on a contract

Parameters​

NameTypeDefault valueDescription
methodstringundefinedname of the method
argsArgsOrCalldata[]Array of the arguments for the call
Β«destructuredΒ»CallOptions{}optional blockIdentifier

Returns​

Promise<Result>

Result of the call as an array with key value pars

Implementation of​

ContractInterface.call

Defined in​

src/contract/default.ts:220


invoke​

β–Έ invoke(method, args?, Β«destructuredΒ»?): Promise<InvokeFunctionResponse>

Invokes a method on a contract

Parameters​

NameTypeDefault valueDescription
methodstringundefinedname of the method
argsArgsOrCalldata[]Array of the arguments for the invoke or Calldata
Β«destructuredΒ»InvokeOptions{}

Returns​

Promise<InvokeFunctionResponse>

Add Transaction Response

Implementation of​

ContractInterface.invoke

Defined in​

src/contract/default.ts:262


estimate​

β–Έ estimate(method, args?): Promise<EstimateFeeResponse>

Estimates a method on a contract

Parameters​

NameTypeDefault valueDescription
methodstringundefinedname of the method
argsArgsOrCalldata[]Array of the arguments for the call or Calldata

Returns​

Promise<EstimateFeeResponse>

Implementation of​

ContractInterface.estimate

Defined in​

src/contract/default.ts:306


populate​

β–Έ populate(method, args?): Call

Calls a method on a contract

Parameters​

NameTypeDefault valueDescription
methodstringundefinedname of the method
argsRawArgs[]Array of the arguments for the call or Calldata

Returns​

Call

Invocation object

Implementation of​

ContractInterface.populate

Defined in​

src/contract/default.ts:320


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

Implementation of​

ContractInterface.parseEvents

Defined in​

src/contract/default.ts:329


isCairo1​

β–Έ isCairo1(): boolean

tells if the contract comes from a Cairo 1 contract

Example

const isCairo1: boolean = myContract.isCairo1();

Returns​

boolean

TRUE if the contract comes from a Cairo1 contract

Implementation of​

ContractInterface.isCairo1

Defined in​

src/contract/default.ts:341


getVersion​

β–Έ getVersion(): Promise<ContractVersion>

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

Returns​

Promise<ContractVersion>

Implementation of​

ContractInterface.getVersion

Defined in​

src/contract/default.ts:345


typed​

β–Έ typed<TAbi>(tAbi): TypedContract<TAbi>

Type parameters​

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

Parameters​

NameType
tAbiTAbi

Returns​

TypedContract<TAbi>

Implementation of​

ContractInterface.typed

Defined in​

src/contract/default.ts:349