Class: Provider
Hierarchy​
Provider
↳
Account
Implements​
Constructors​
constructor​
• new Provider(providerOrOptions?
)
Parameters​
Name | Type |
---|---|
providerOrOptions? | ProviderOptions | ProviderInterface |
Defined in​
Properties​
provider​
• Private
provider: ProviderInterface
Defined in​
Methods​
getChainId​
â–¸ getChainId(): Promise
<StarknetChainId
>
Gets the Starknet chain Id
Returns​
Promise
<StarknetChainId
>
the chain Id
Implementation of​
Defined in​
getBlock​
â–¸ getBlock(blockIdentifier
): Promise
<GetBlockResponse
>
Gets the block information
Parameters​
Name | Type | Description |
---|---|---|
blockIdentifier | BlockIdentifier | block identifier |
Returns​
Promise
<GetBlockResponse
>
the block object
Implementation of​
Defined in​
getClassAt​
â–¸ getClassAt(contractAddress
, blockIdentifier?
): Promise
<ContractClassResponse
>
Gets the contract class of the deployed contract.
Parameters​
Name | Type | Description |
---|---|---|
contractAddress | string | contract address |
blockIdentifier? | BlockIdentifier | block identifier |
Returns​
Promise
<ContractClassResponse
>
Contract class of compiled contract
Implementation of​
Defined in​
getClassHashAt​
â–¸ getClassHashAt(contractAddress
, blockIdentifier?
): Promise
<string
>
Returns the class hash deployed under the given address.
Parameters​
Name | Type | Description |
---|---|---|
contractAddress | string | contract address |
blockIdentifier? | BlockIdentifier | block identifier |
Returns​
Promise
<string
>
Class hash
Implementation of​
ProviderInterface.getClassHashAt
Defined in​
getClassByHash​
â–¸ getClassByHash(classHash
): Promise
<ContractClassResponse
>
Returns the contract class deployed under the given class hash.
Parameters​
Name | Type | Description |
---|---|---|
classHash | string | class hash |
Returns​
Promise
<ContractClassResponse
>
Contract class of compiled contract
Implementation of​
ProviderInterface.getClassByHash
Defined in​
getEstimateFee​
â–¸ getEstimateFee(invocationWithTxType
, invocationDetails
, blockIdentifier
): Promise
<EstimateFeeResponse
>
Estimates the fee for a given INVOKE transaction
Deprecated
Please use getInvokeEstimateFee or getDeclareEstimateFee instead. Should not be used outside of Account class
Parameters​
Name | Type | Description |
---|---|---|
invocationWithTxType | Invocation | the invocation object containing: - contractAddress - the address of the contract - entrypoint - the entrypoint of the contract - calldata - (defaults to []) the calldata - signature - (defaults to []) the signature |
invocationDetails | InvocationsDetailsWithNonce | optional details containing: - nonce - optional nonce - version - optional version |
blockIdentifier | BlockIdentifier | (optional) block identifier |
Returns​
Promise
<EstimateFeeResponse
>
the estimated fee
Implementation of​
ProviderInterface.getEstimateFee
Defined in​
getInvokeEstimateFee​
â–¸ getInvokeEstimateFee(invocationWithTxType
, invocationDetails
, blockIdentifier?
, skipValidate?
): Promise
<EstimateFeeResponse
>
Estimates the fee for a given INVOKE transaction
Parameters​
Name | Type | Description |
---|---|---|
invocationWithTxType | Invocation | the invocation object containing: - contractAddress - the address of the contract - entrypoint - the entrypoint of the contract - calldata - (defaults to []) the calldata - signature - (defaults to []) the signature |
invocationDetails | InvocationsDetailsWithNonce | optional details containing: - nonce - optional nonce - version - optional version |
blockIdentifier? | BlockIdentifier | (optional) block identifier |
skipValidate? | boolean | (optional) skip cairo validate method |
Returns​
Promise
<EstimateFeeResponse
>
the estimated fee
Implementation of​
ProviderInterface.getInvokeEstimateFee
Defined in​
getEstimateFeeBulk​
â–¸ getEstimateFeeBulk(invocations
, options
): Promise
<EstimateFeeResponseBulk
>
Estimates the fee for a list of INVOKE transaction
Parameters​
Name | Type | Description |
---|---|---|
invocations | AccountInvocations | AccountInvocations - Complete invocations array with account details |
options | getEstimateFeeBulkOptions | getEstimateFeeBulkOptions - (optional) blockIdentifier - BlockIdentifier - (optional) skipValidate - boolean (default false) |
Returns​
Promise
<EstimateFeeResponseBulk
>
the estimated fee
Implementation of​
ProviderInterface.getEstimateFeeBulk
Defined in​
getNonceForAddress​
â–¸ getNonceForAddress(contractAddress
, blockIdentifier?
): Promise
<string
>
Gets the nonce of a contract with respect to a specific block
Parameters​
Name | Type | Description |
---|---|---|
contractAddress | string | contract address |
blockIdentifier? | BlockIdentifier | - |
Returns​
Promise
<string
>
the hex nonce
Implementation of​
ProviderInterface.getNonceForAddress
Defined in​
getStorageAt​
â–¸ getStorageAt(contractAddress
, key
, blockIdentifier?
): Promise
<string
>
Gets the contract's storage variable at a specific key.
Parameters​
Name | Type | Description |
---|---|---|
contractAddress | string | |
key | BigNumberish | from getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP) |
blockIdentifier? | BlockIdentifier | block identifier |
Returns​
Promise
<string
>
the value of the storage variable
Implementation of​
ProviderInterface.getStorageAt
Defined in​
getTransaction​
â–¸ getTransaction(txHash
): Promise
<GetTransactionResponse
>
Gets the transaction information from a tx id.
Parameters​
Name | Type |
---|---|
txHash | BigNumberish |
Returns​
Promise
<GetTransactionResponse
>
the transaction object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }
Implementation of​
ProviderInterface.getTransaction
Defined in​
getTransactionReceipt​
â–¸ getTransactionReceipt(txHash
): Promise
<GetTransactionReceiptResponse
>
Gets the transaction receipt from a tx hash.
Parameters​
Name | Type |
---|---|
txHash | BigNumberish |
Returns​
Promise
<GetTransactionReceiptResponse
>
the transaction receipt object
Implementation of​
ProviderInterface.getTransactionReceipt
Defined in​
callContract​
â–¸ callContract(request
, blockIdentifier?
): Promise
<CallContractResponse
>
Calls a function on the Starknet contract.
Parameters​
Name | Type | Description |
---|---|---|
request | Call | transaction to be called |
blockIdentifier? | BlockIdentifier | block identifier |
Returns​
Promise
<CallContractResponse
>
the result of the function on the smart contract.
Implementation of​
ProviderInterface.callContract
Defined in​
invokeFunction​
â–¸ invokeFunction(functionInvocation
, details
): Promise
<InvokeFunctionResponse
>
Invokes a function on starknet
Deprecated
This method won't be supported as soon as fees are mandatory. Should not be used outside of Account class
Parameters​
Name | Type | Description |
---|---|---|
functionInvocation | Invocation | the invocation object containing: - contractAddress - the address of the contract - entrypoint - the entrypoint of the contract - calldata - (defaults to []) the calldata - signature - (defaults to []) the signature |
details | InvocationsDetailsWithNonce | optional details containing: - nonce - optional nonce - version - optional version - maxFee - optional maxFee |
Returns​
Promise
<InvokeFunctionResponse
>
response from addTransaction
Implementation of​
ProviderInterface.invokeFunction
Defined in​
deployAccountContract​
â–¸ deployAccountContract(payload
, details
): Promise
<DeployContractResponse
>
Deploys a given compiled Account contract (json) to starknet
Parameters​
Name | Type | Description |
---|---|---|
payload | DeployAccountContractTransaction | payload to be deployed containing: - compiled contract code - constructor calldata - address salt |
details | InvocationsDetailsWithNonce | - |
Returns​
Promise
<DeployContractResponse
>
a confirmation of sending a transaction on the starknet contract
Implementation of​
ProviderInterface.deployAccountContract
Defined in​
declareContract​
â–¸ declareContract(transaction
, details
): Promise
<DeclareContractResponse
>
Declares a given compiled contract (json) to starknet
Parameters​
Name | Type | Description |
---|---|---|
transaction | DeclareContractTransaction | transaction payload to be deployed containing: - compiled contract code - sender address - signature |
details | InvocationsDetailsWithNonce | Invocation Details containing: - nonce - optional version - optional maxFee |
Returns​
Promise
<DeclareContractResponse
>
a confirmation of sending a transaction on the starknet contract
Implementation of​
ProviderInterface.declareContract
Defined in​
getDeclareEstimateFee​
â–¸ getDeclareEstimateFee(transaction
, details
, blockIdentifier?
, skipValidate?
): Promise
<EstimateFeeResponse
>
Estimates the fee for a given DECLARE transaction
Parameters​
Name | Type | Description |
---|---|---|
transaction | DeclareContractTransaction | transaction payload to be declared containing: - compiled contract code - sender address - signature - (defaults to []) the signature |
details | InvocationsDetailsWithNonce | optional details containing: - nonce - version - optional version - optional maxFee |
blockIdentifier? | BlockIdentifier | (optional) block identifier |
skipValidate? | boolean | (optional) skip cairo validate method |
Returns​
Promise
<EstimateFeeResponse
>
the estimated fee
Implementation of​
ProviderInterface.getDeclareEstimateFee
Defined in​
getDeployAccountEstimateFee​
â–¸ getDeployAccountEstimateFee(transaction
, details
, blockIdentifier?
, skipValidate?
): Promise
<EstimateFeeResponse
>
Estimates the fee for a given DEPLOY_ACCOUNT transaction
Parameters​
Name | Type | Description |
---|---|---|
transaction | DeployAccountContractTransaction | transaction payload to be deployed containing: - classHash - constructorCalldata - addressSalt - signature - (defaults to []) the signature |
details | InvocationsDetailsWithNonce | optional details containing: - nonce - version - optional version - optional maxFee |
blockIdentifier? | BlockIdentifier | (optional) block identifier |
skipValidate? | boolean | (optional) skip cairo validate method |
Returns​
Promise
<EstimateFeeResponse
>
the estimated fee
Implementation of​
ProviderInterface.getDeployAccountEstimateFee
Defined in​
getCode​
â–¸ getCode(contractAddress
, blockIdentifier?
): Promise
<GetCodeResponse
>
Deprecated
The method should not be used
Parameters​
Name | Type |
---|---|
contractAddress | string |
blockIdentifier? | BlockIdentifier |
Returns​
Promise
<GetCodeResponse
>
Implementation of​
Defined in​
waitForTransaction​
â–¸ waitForTransaction(txHash
, options?
): Promise
<GetTransactionReceiptResponse
>
Wait for the transaction to be accepted
Parameters​
Name | Type | Description |
---|---|---|
txHash | BigNumberish | transaction hash |
options? | waitForTransactionOptions | waitForTransactionOptions - (optional) retryInterval: number | undefined; - (optional) successStates: TransactionStatus[] | undefined; |
Returns​
Promise
<GetTransactionReceiptResponse
>
GetTransactionReceiptResponse
Implementation of​
ProviderInterface.waitForTransaction
Defined in​
getSimulateTransaction​
â–¸ getSimulateTransaction(invocations
, options?
): Promise
<SimulateTransactionResponse
>
Simulates the transaction and returns the transaction trace and estimated fee.
Parameters​
Name | Type | Description |
---|---|---|
invocations | AccountInvocations | AccountInvocations - Complete invocations array with account details |
options? | getSimulateTransactionOptions | getSimulateTransactionOptions - (optional) blockIdentifier - block identifier - (optional) skipValidate - skip cairo validate method - (optional) skipExecute - skip cairo execute method |
Returns​
Promise
<SimulateTransactionResponse
>
an array of transaction trace and estimated fee
Implementation of​
ProviderInterface.getSimulateTransaction
Defined in​
getStateUpdate​
â–¸ getStateUpdate(blockIdentifier?
): Promise
<StateUpdateResponse
>
Gets the state changes in a specific block
Parameters​
Name | Type | Description |
---|---|---|
blockIdentifier? | BlockIdentifier | block identifier |
Returns​
Promise
<StateUpdateResponse
>
StateUpdateResponse
Implementation of​
ProviderInterface.getStateUpdate
Defined in​
getStarkName​
â–¸ getStarkName(address
, StarknetIdContract?
): Promise
<string
>
Parameters​
Name | Type |
---|---|
address | BigNumberish |
StarknetIdContract? | string |
Returns​
Promise
<string
>
Defined in​
getAddressFromStarkName​
â–¸ getAddressFromStarkName(name
, StarknetIdContract?
): Promise
<string
>
Parameters​
Name | Type |
---|---|
name | string |
StarknetIdContract? | string |
Returns​
Promise
<string
>