Skip to main content
Version: Next

Class: Contract

Implements​

Indexable​

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

Constructors​

constructor​

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

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

Returns​

Contract

Defined in​

src/contract/default.ts:150

Properties​

abi​

β€’ abi: Abi

Implementation of​

ContractInterface.abi

Defined in​

src/contract/default.ts:119


address​

β€’ address: string

Implementation of​

ContractInterface.address

Defined in​

src/contract/default.ts:121


providerOrAccount​

β€’ providerOrAccount: ProviderInterface | AccountInterface

Implementation of​

ContractInterface.providerOrAccount

Defined in​

src/contract/default.ts:123


deployTransactionHash​

β€’ Optional deployTransactionHash: string

Implementation of​

ContractInterface.deployTransactionHash

Defined in​

src/contract/default.ts:125


structs​

β€’ Protected Readonly structs: Object

Index signature​

β–ͺ [name: string]: AbiStruct

Defined in​

src/contract/default.ts:127


events​

β€’ Protected Readonly events: AbiEvents

Defined in​

src/contract/default.ts:129


functions​

β€’ Readonly functions: Object

Index signature​

β–ͺ [name: string]: AsyncContractFunction

Implementation of​

ContractInterface.functions

Defined in​

src/contract/default.ts:131


callStatic​

β€’ Readonly callStatic: Object

Index signature​

β–ͺ [name: string]: AsyncContractFunction

Implementation of​

ContractInterface.callStatic

Defined in​

src/contract/default.ts:133


populateTransaction​

β€’ Readonly populateTransaction: Object

Index signature​

β–ͺ [name: string]: ContractFunction

Implementation of​

ContractInterface.populateTransaction

Defined in​

src/contract/default.ts:135


estimateFee​

β€’ Readonly estimateFee: Object

Index signature​

β–ͺ [name: string]: ContractFunction

Implementation of​

ContractInterface.estimateFee

Defined in​

src/contract/default.ts:137


callData​

β€’ Private callData: CallData

Defined in​

src/contract/default.ts:141

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


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


deployed​

β–Έ deployed(): Promise<Contract>

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

Returns​

Promise<Contract>

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

Throws

When deployment fails

Implementation of​

ContractInterface.deployed

Defined in​

src/contract/default.ts:214


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


invoke​

β–Έ invoke(method, args?, Β«destructuredΒ»?): Promise<{ transaction_hash: string }>

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<{ transaction_hash: string }>

Add Transaction Response

Implementation of​

ContractInterface.invoke

Defined in​

src/contract/default.ts:264


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


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


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


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();

Implementation of​

ContractInterface.isCairo1

Defined in​

src/contract/default.ts:343


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


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.

Implementation of​

ContractInterface.typedv2

Defined in​

src/contract/default.ts:351