Class: Contract
Implementsβ
Indexableβ
βͺ [key: string
]: AsyncContractFunction
| any
Constructorsβ
constructorβ
β’ new Contract(abi
, address
, providerOrAccount?
): Contract
Contract class to handle contract methods
Parametersβ
Name | Type | Default value | Description |
---|---|---|---|
abi | Abi | undefined | Abi of the contract object |
address | string | undefined | (optional) - address to connect to |
providerOrAccount | ProviderInterface | AccountInterface | defaultProvider | (optional) - Provider or Account to attach to |
Returnsβ
Defined inβ
Propertiesβ
abiβ
β’ abi: Abi
Implementation ofβ
Defined inβ
addressβ
β’ address: string
Implementation ofβ
Defined inβ
providerOrAccountβ
β’ providerOrAccount: ProviderInterface
| AccountInterface
Implementation ofβ
ContractInterface.providerOrAccount
Defined inβ
deployTransactionHashβ
β’ Optional
deployTransactionHash: string
Implementation ofβ
ContractInterface.deployTransactionHash
Defined inβ
structsβ
β’ Protected
Readonly
structs: Object
Index signatureβ
βͺ [name: string
]: AbiStruct
Defined inβ
eventsβ
β’ Protected
Readonly
events: AbiEvents
Defined inβ
functionsβ
β’ Readonly
functions: Object
Index signatureβ
βͺ [name: string
]: AsyncContractFunction
Implementation ofβ
Defined inβ
callStaticβ
β’ Readonly
callStatic: Object
Index signatureβ
βͺ [name: string
]: AsyncContractFunction
Implementation ofβ
Defined inβ
populateTransactionβ
β’ Readonly
populateTransaction: Object
Index signatureβ
βͺ [name: string
]: ContractFunction
Implementation ofβ
ContractInterface.populateTransaction
Defined inβ
estimateFeeβ
β’ Readonly
estimateFee: Object
Index signatureβ
βͺ [name: string
]: ContractFunction
Implementation ofβ
Defined inβ
callDataβ
β’ Private
callData: CallData
Defined inβ
Methodsβ
attachβ
βΈ attach(address
): void
Saves the address of the contract deployed on network that will be used for interaction
Parametersβ
Name | Type | Description |
---|---|---|
address | string | address of the contract |
Returnsβ
void
Implementation ofβ
Defined inβ
connectβ
βΈ connect(providerOrAccount
): void
Attaches to new Provider or Account
Parametersβ
Name | Type | Description |
---|---|---|
providerOrAccount | ProviderInterface | AccountInterface | new Provider or Account to attach to |
Returnsβ
void
Implementation ofβ
Defined inβ
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β
Defined inβ
callβ
βΈ call(method
, args?
, Β«destructuredΒ»?
): Promise
<Result
>
Calls a method on a contract
Parametersβ
Name | Type | Default value | Description |
---|---|---|---|
method | string | undefined | name of the method |
args | ArgsOrCalldata | [] | 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β
Defined inβ
invokeβ
βΈ invoke(method
, args?
, Β«destructuredΒ»?
): Promise
<{ transaction_hash
: string
}>
Invokes a method on a contract
Parametersβ
Name | Type | Default value | Description |
---|---|---|---|
method | string | undefined | name of the method |
args | ArgsOrCalldata | [] | Array of the arguments for the invoke or Calldata |
Β«destructuredΒ» | InvokeOptions | {} |
Returnsβ
Promise
<{ transaction_hash
: string
}>
Add Transaction Response
Implementation ofβ
Defined inβ
estimateβ
βΈ estimate(method
, args?
): Promise
<EstimateFeeResponse
>
Estimates a method on a contract
Parametersβ
Name | Type | Default value | Description |
---|---|---|---|
method | string | undefined | name of the method |
args | ArgsOrCalldata | [] | Array of the arguments for the call or Calldata |
Returnsβ
Promise
<EstimateFeeResponse
>
Implementation ofβ
Defined inβ
populateβ
βΈ populate(method
, args?
): Call
Calls a method on a contract
Parametersβ
Name | Type | Default value | Description |
---|---|---|---|
method | string | undefined | name of the method |
args | RawArgs | [] | Array of the arguments for the call or Calldata |
Returnsβ
Invocation object
Implementation ofβ
Defined inβ
parseEventsβ
βΈ parseEvents(receipt
): ParsedEvents
Parse contract events of a GetTransactionReceiptResponse received from waitForTransaction. Based on contract's abi
Parametersβ
Name | Type | Description |
---|---|---|
receipt | GetTransactionReceiptResponse | transaction receipt |
Returnsβ
Events parsed
Implementation ofβ
Defined inβ
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β
Defined inβ
getVersionβ
βΈ getVersion(): Promise
<ContractVersion
>
Retrieves the version of the contract (cairo version & compiler version)
Returnsβ
Promise
<ContractVersion
>
Implementation ofβ
Defined inβ
typedv2β
βΈ typedv2<TAbi
>(tAbi
): TypedContractV2
<TAbi
>
Returns a typed instance of ContractV2 based on the supplied ABI.
Type parametersβ
Name | Type |
---|---|
TAbi | extends readonly (AbiImpl | AbiFunction | AbiInterface | AbiConstructor | AbiEvent | AbiStruct | AbiEnum )[] |
Parametersβ
Name | Type | Description |
---|---|---|
tAbi | TAbi | The ABI (Abstract Binary Interface) of the ContractV2. |
Returnsβ
TypedContractV2
<TAbi
>
- A typed instance of ContractV2.