@0xknwn/starknet-test-helpers / Counter
Class: Counter
Defined in: sdks/__tests__/helpers/src/counter.ts:52
Represents a Counter contract.
Extends
Contract
Indexable
[key
: string
]: any
Constructors
new Counter()
new Counter(
address
,account
):Counter
Defined in: sdks/__tests__/helpers/src/counter.ts:58
Creates an instance of the Counter contract.
Parameters
address
string
The address of the contract.
account
Account
The account used to interact with the contract.
Returns
Overrides
Contract.constructor
Properties
abi
abi:
Abi
Defined in: node_modules/starknet/dist/index.d.ts:4743
Inherited from
Contract.abi
address
address:
string
Defined in: node_modules/starknet/dist/index.d.ts:4744
Inherited from
Contract.address
callStatic
readonly
callStatic:object
Defined in: node_modules/starknet/dist/index.d.ts:4754
Index Signature
[name
: string
]: AsyncContractFunction
<any
>
Inherited from
Contract.callStatic
deployTransactionHash?
optional
deployTransactionHash:string
Defined in: node_modules/starknet/dist/index.d.ts:4746
Inherited from
Contract.deployTransactionHash
estimateFee
readonly
estimateFee:object
Defined in: node_modules/starknet/dist/index.d.ts:4760
Index Signature
[name
: string
]: ContractFunction
Inherited from
Contract.estimateFee
events
protected
readonly
events:AbiEvents
Defined in: node_modules/starknet/dist/index.d.ts:4750
Inherited from
Contract.events
functions
readonly
functions:object
Defined in: node_modules/starknet/dist/index.d.ts:4751
Index Signature
[name
: string
]: AsyncContractFunction
<any
>
Inherited from
Contract.functions
populateTransaction
readonly
populateTransaction:object
Defined in: node_modules/starknet/dist/index.d.ts:4757
Index Signature
[name
: string
]: ContractFunction
Inherited from
Contract.populateTransaction
providerOrAccount
providerOrAccount:
ProviderInterface
|AccountInterface
Defined in: node_modules/starknet/dist/index.d.ts:4745
Inherited from
Contract.providerOrAccount
structs
protected
readonly
structs:object
Defined in: node_modules/starknet/dist/index.d.ts:4747
Index Signature
[name
: string
]: AbiStruct
Inherited from
Contract.structs
Methods
attach()
attach(
address
):void
Defined in: node_modules/starknet/dist/index.d.ts:4773
Saves the address of the contract deployed on network that will be used for interaction
Parameters
address
string
address of the contract
Returns
void
Inherited from
Contract.attach
call()
call(
method
,args
?,options
?):Promise
<Result
>
Defined in: node_modules/starknet/dist/index.d.ts:4776
Calls a method on a contract
Parameters
method
string
name of the method
args?
ArgsOrCalldata
Array of the arguments for the call
options?
CallOptions
optional blockIdentifier
Returns
Promise
<Result
>
Result of the call as an array with key value pars
Inherited from
Contract.call
connect()
connect(
providerOrAccount
):void
Defined in: node_modules/starknet/dist/index.d.ts:4774
Attaches to new Provider or Account
Parameters
providerOrAccount
new Provider or Account to attach to
ProviderInterface
| AccountInterface
Returns
void
Inherited from
Contract.connect
deployed()
deployed():
Promise
<Contract
>
Defined in: node_modules/starknet/dist/index.d.ts:4775
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
Inherited from
Contract.deployed
estimate()
estimate(
method
,args
?):Promise
<EstimateFeeResponse
>
Defined in: node_modules/starknet/dist/index.d.ts:4778
Estimates a method on a contract
Parameters
method
string
name of the method
args?
ArgsOrCalldata
Array of the arguments for the call or Calldata
Returns
Promise
<EstimateFeeResponse
>
Inherited from
Contract.estimate
getVersion()
getVersion():
Promise
<ContractVersion
>
Defined in: node_modules/starknet/dist/index.d.ts:4782
Retrieves the version of the contract (cairo version & compiler version)
Returns
Promise
<ContractVersion
>
Inherited from
Contract.getVersion
increment()
increment():
Promise
<{transaction_hash
:string
; }>
Defined in: sdks/__tests__/helpers/src/counter.ts:66
Increments the counter by 1.
Returns
Promise
<{ transaction_hash
: string
; }>
A promise that resolves to the result of the execution.
increment_by()
increment_by(
value
):Promise
<{transaction_hash
:string
; }>
Defined in: sdks/__tests__/helpers/src/counter.ts:77
Increments the counter by the specified value.
Parameters
value
number
The value to increment the counter by.
Returns
Promise
<{ transaction_hash
: string
; }>
A promise that resolves to the result of the execution.
increment_by_array()
increment_by_array(
args
):Promise
<{transaction_hash
:string
; }>
Defined in: sdks/__tests__/helpers/src/counter.ts:106
Increments the counter by an array of numbers using increment_by_array.
Parameters
args
number
[]
The array of values to increment the counter by.
Returns
Promise
<{ transaction_hash
: string
; }>
A promise that resolves to the result of the execution.
increment_by_multicall()
increment_by_multicall(
values
):Promise
<{transaction_hash
:string
; }>
Defined in: sdks/__tests__/helpers/src/counter.ts:88
Increments the counter by an array of numbers using a multicall of increment_by.
Parameters
values
number
[]
The array of values to increment the counter by.
Returns
Promise
<{ transaction_hash
: string
; }>
A promise that resolves to the result of the execution.
invoke()
invoke(
method
,args
?,options
?):Promise
<{transaction_hash
:string
; }>
Defined in: node_modules/starknet/dist/index.d.ts:4777
Invokes a method on a contract
Parameters
method
string
name of the method
args?
ArgsOrCalldata
Array of the arguments for the invoke or Calldata
options?
InvokeOptions
Returns
Promise
<{ transaction_hash
: string
; }>
Add Transaction Response
Inherited from
Contract.invoke
isCairo1()
isCairo1():
boolean
Defined in: node_modules/starknet/dist/index.d.ts:4781
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();
Inherited from
Contract.isCairo1
parseEvents()
parseEvents(
receipt
):ParsedEvents
Defined in: node_modules/starknet/dist/index.d.ts:4780
Parse contract events of a GetTransactionReceiptResponse received from waitForTransaction. Based on contract's abi
Parameters
receipt
GetTransactionReceiptResponse
transaction receipt
Returns
ParsedEvents
Events parsed
Inherited from
Contract.parseEvents
populate()
populate(
method
,args
?):Call
Defined in: node_modules/starknet/dist/index.d.ts:4779
Calls a method on a contract
Parameters
method
string
name of the method
args?
RawArgs
Array of the arguments for the call or Calldata
Returns
Call
Invocation object
Inherited from
Contract.populate
reset()
reset():
Promise
<{transaction_hash
:string
; }>
Defined in: sdks/__tests__/helpers/src/counter.ts:120
Resets the counter.
Returns
Promise
<{ transaction_hash
: string
; }>
A promise that resolves to the result of the execution.
Remarks
This function requires the Account used by the Counter to be its owner.
typedv2()
typedv2<
TAbi
>(tAbi
):TypedContractV2
<TAbi
>
Defined in: node_modules/starknet/dist/index.d.ts:4783
Returns a typed instance of ContractV2 based on the supplied ABI.
Type Parameters
• TAbi extends Abi
Parameters
tAbi
TAbi
The ABI (Abstract Binary Interface) of the ContractV2.
Returns
TypedContractV2
<TAbi
>
- A typed instance of ContractV2.
Inherited from
Contract.typedv2