Skip to main content
Version: Next

Class: Provider

Hierarchy

Implements

Constructors

constructor

new Provider(providerOrOptions?)

Parameters

NameType
providerOrOptions?ProviderInterface | ProviderOptions

Defined in

src/provider/default.ts:42

Properties

provider

Private provider: ProviderInterface

Defined in

src/provider/default.ts:40

Methods

getChainId

getChainId(): Promise<StarknetChainId>

Gets the Starknet chain Id

Returns

Promise<StarknetChainId>

the chain Id

Implementation of

ProviderInterface.getChainId

Defined in

src/provider/default.ts:64


getBlock

getBlock(blockIdentifier): Promise<GetBlockResponse>

Gets the block information

Parameters

NameTypeDescription
blockIdentifierBlockIdentifierblock identifier

Returns

Promise<GetBlockResponse>

the block object

Implementation of

ProviderInterface.getBlock

Defined in

src/provider/default.ts:68


getClassAt

getClassAt(contractAddress, blockIdentifier?): Promise<ContractClass | CONTRACT_CLASS>

Gets the contract class of the deployed contract.

Parameters

NameTypeDescription
contractAddressstringcontract address
blockIdentifier?BlockIdentifierblock identifier

Returns

Promise<ContractClass | CONTRACT_CLASS>

Contract class of compiled contract

Implementation of

ProviderInterface.getClassAt

Defined in

src/provider/default.ts:72


getClassHashAt

getClassHashAt(contractAddress, blockIdentifier?): Promise<string>

Returns the class hash deployed under the given address.

Parameters

NameTypeDescription
contractAddressstringcontract address
blockIdentifier?BlockIdentifierblock identifier

Returns

Promise<string>

Class hash

Implementation of

ProviderInterface.getClassHashAt

Defined in

src/provider/default.ts:79


getClassByHash

getClassByHash(classHash): Promise<ContractClass | CONTRACT_CLASS>

Returns the contract class deployed under the given class hash.

Parameters

NameTypeDescription
classHashstringclass hash

Returns

Promise<ContractClass | CONTRACT_CLASS>

Contract class of compiled contract

Implementation of

ProviderInterface.getClassByHash

Defined in

src/provider/default.ts:86


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

NameTypeDescription
invocationWithTxTypeInvocationthe 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
invocationDetailsInvocationsDetailsWithNonceoptional details containing: - nonce - optional nonce - version - optional version
blockIdentifierBlockIdentifier(optional) block identifier

Returns

Promise<EstimateFeeResponse>

the estimated fee

Implementation of

ProviderInterface.getEstimateFee

Defined in

src/provider/default.ts:90


getInvokeEstimateFee

getInvokeEstimateFee(invocationWithTxType, invocationDetails, blockIdentifier?, skipValidate?): Promise<EstimateFeeResponse>

Estimates the fee for a given INVOKE transaction

Parameters

NameTypeDescription
invocationWithTxTypeInvocationthe 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
invocationDetailsInvocationsDetailsWithNonceoptional 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

src/provider/default.ts:98


getEstimateFeeBulk

getEstimateFeeBulk(invocations, blockIdentifier?): Promise<EstimateFeeResponseBulk>

Estimates the fee for a list of INVOKE transaction

Parameters

NameTypeDescription
invocationsInvocationBulkthe array of invocation and invocation details object containing: - contractAddress - the address of the account - calldata - (defaults to []) the calldata - signature - (defaults to []) the signature - nonce - optional nonce - version - optional version
blockIdentifier?BlockIdentifierblock identifier

Returns

Promise<EstimateFeeResponseBulk>

the estimated fee

Implementation of

ProviderInterface.getEstimateFeeBulk

Defined in

src/provider/default.ts:112


getNonceForAddress

getNonceForAddress(contractAddress, blockIdentifier?): Promise<string>

Gets the nonce of a contract with respect to a specific block

Parameters

NameTypeDescription
contractAddressstringcontract address
blockIdentifier?BlockIdentifier-

Returns

Promise<string>

the hex nonce

Implementation of

ProviderInterface.getNonceForAddress

Defined in

src/provider/default.ts:119


getStorageAt

getStorageAt(contractAddress, key, blockIdentifier?): Promise<string>

Gets the contract's storage variable at a specific key.

Parameters

NameTypeDescription
contractAddressstring
keyBigNumberishfrom getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)
blockIdentifier?BlockIdentifierblock identifier

Returns

Promise<string>

the value of the storage variable

Implementation of

ProviderInterface.getStorageAt

Defined in

src/provider/default.ts:126


getTransaction

getTransaction(txHash): Promise<GetTransactionResponse>

Gets the transaction information from a tx id.

Parameters

NameType
txHashBigNumberish

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

src/provider/default.ts:134


getTransactionReceipt

getTransactionReceipt(txHash): Promise<GetTransactionReceiptResponse>

Gets the transaction receipt from a tx hash.

Parameters

NameType
txHashBigNumberish

Returns

Promise<GetTransactionReceiptResponse>

the transaction receipt object

Implementation of

ProviderInterface.getTransactionReceipt

Defined in

src/provider/default.ts:138


callContract

callContract(request, blockIdentifier?): Promise<CallContractResponse>

Calls a function on the Starknet contract.

Parameters

NameTypeDescription
requestCalltransaction to be called
blockIdentifier?BlockIdentifierblock identifier

Returns

Promise<CallContractResponse>

the result of the function on the smart contract.

Implementation of

ProviderInterface.callContract

Defined in

src/provider/default.ts:142


invokeFunction

invokeFunction(functionInvocation, details): Promise<InvokeFunctionResponse>

Invokes a function on starknet

Deprecated

This method wont be supported as soon as fees are mandatory. Should not be used outside of Account class

Parameters

NameTypeDescription
functionInvocationInvocationthe 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
detailsInvocationsDetailsWithNonceoptional details containing: - nonce - optional nonce - version - optional version - maxFee - optional maxFee

Returns

Promise<InvokeFunctionResponse>

response from addTransaction

Implementation of

ProviderInterface.invokeFunction

Defined in

src/provider/default.ts:149


deployAccountContract

deployAccountContract(payload, details): Promise<DeployContractResponse>

Deploys a given compiled Account contract (json) to starknet

Parameters

NameTypeDescription
payloadDeployAccountContractTransactionpayload to be deployed containing: - compiled contract code - constructor calldata - address salt
detailsInvocationsDetailsWithNonce-

Returns

Promise<DeployContractResponse>

a confirmation of sending a transaction on the starknet contract

Implementation of

ProviderInterface.deployAccountContract

Defined in

src/provider/default.ts:156


declareContract

declareContract(transaction, details): Promise<DeclareContractResponse>

Declares a given compiled contract (json) to starknet

Parameters

NameTypeDescription
transactionDeclareContractTransactiontransaction payload to be deployed containing: - compiled contract code - sender address - signature
detailsInvocationsDetailsWithNonceInvocation 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

src/provider/default.ts:163


getDeclareEstimateFee

getDeclareEstimateFee(transaction, details, blockIdentifier?, skipValidate?): Promise<EstimateFeeResponse>

Estimates the fee for a given DECLARE transaction

Parameters

NameTypeDescription
transactionDeclareContractTransactiontransaction payload to be declared containing: - compiled contract code - sender address - signature - (defaults to []) the signature
detailsInvocationsDetailsWithNonceoptional 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

src/provider/default.ts:170


getDeployAccountEstimateFee

getDeployAccountEstimateFee(transaction, details, blockIdentifier?, skipValidate?): Promise<EstimateFeeResponse>

Estimates the fee for a given DEPLOY_ACCOUNT transaction

Parameters

NameTypeDescription
transactionDeployAccountContractTransactiontransaction payload to be deployed containing: - classHash - constructorCalldata - addressSalt - signature - (defaults to []) the signature
detailsInvocationsDetailsWithNonceoptional 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

src/provider/default.ts:179


getCode

getCode(contractAddress, blockIdentifier?): Promise<GetCodeResponse>

Deprecated

The method should not be used

Parameters

NameType
contractAddressstring
blockIdentifier?BlockIdentifier

Returns

Promise<GetCodeResponse>

Implementation of

ProviderInterface.getCode

Defined in

src/provider/default.ts:193


waitForTransaction

waitForTransaction(txHash, options?): Promise<GetTransactionReceiptResponse>

Wait for the transaction to be accepted

Parameters

NameTypeDescription
txHashBigNumberishtransaction hash
options?waitForTransactionOptions(optional) retryInterval: number | undefined; - (optional) successStates: TransactionStatus[] | undefined;

Returns

Promise<GetTransactionReceiptResponse>

GetTransactionReceiptResponse

Implementation of

ProviderInterface.waitForTransaction

Defined in

src/provider/default.ts:200


getSimulateTransaction

getSimulateTransaction(invocation, invocationDetails, blockIdentifier?, skipValidate?): Promise<TransactionSimulationResponse>

Simulates the transaction and returns the transaction trace and estimated fee.

Parameters

NameTypeDescription
invocationInvocationthe 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
invocationDetailsInvocationsDetailsWithNonce-
blockIdentifier?BlockIdentifier(optional) block identifier
skipValidate?boolean(optional) skip cairo validate method

Returns

Promise<TransactionSimulationResponse>

the transaction trace and estimated fee

Implementation of

ProviderInterface.getSimulateTransaction

Defined in

src/provider/default.ts:207


getStateUpdate

getStateUpdate(blockIdentifier?): Promise<StateUpdateResponse>

Gets the state changes in a specific block

Parameters

NameTypeDescription
blockIdentifier?BlockIdentifierblock identifier

Returns

Promise<StateUpdateResponse>

StateUpdateResponse

Implementation of

ProviderInterface.getStateUpdate

Defined in

src/provider/default.ts:221


getStarkName

getStarkName(address, StarknetIdContract?): Promise<string>

Parameters

NameType
addressBigNumberish
StarknetIdContract?string

Returns

Promise<string>

Defined in

src/provider/default.ts:225


getAddressFromStarkName

getAddressFromStarkName(name, StarknetIdContract?): Promise<string>

Parameters

NameType
namestring
StarknetIdContract?string

Returns

Promise<string>

Defined in

src/provider/default.ts:229