Class: RpcProvider
Implementsβ
Constructorsβ
constructorβ
β’ new RpcProvider(optionsOrProvider
)
Parametersβ
Name | Type |
---|---|
optionsOrProvider | RpcProviderOptions |
Defined inβ
Propertiesβ
nodeUrlβ
β’ nodeUrl: string
Defined inβ
headersβ
β’ headers: object
Defined inβ
responseParserβ
β’ Private
responseParser: RPCResponseParser
Defined inβ
retriesβ
β’ Private
retries: number
Defined inβ
blockIdentifierβ
β’ Private
blockIdentifier: BlockIdentifier
Defined inβ
chainIdβ
β’ Private
Optional
chainId: StarknetChainId
Defined inβ
Methodsβ
fetchβ
βΈ fetch(method
, params
): Promise
<any
>
Parametersβ
Name | Type |
---|---|
method | any |
params | any |
Returnsβ
Promise
<any
>
Defined inβ
errorHandlerβ
βΈ Protected
errorHandler(error
): void
Parametersβ
Name | Type |
---|---|
error | any |
Returnsβ
void
Defined inβ
fetchEndpointβ
βΈ Protected
fetchEndpoint<T
>(method
, params?
): Promise
<Methods
[T
][``"result"``]>
Type parametersβ
Name | Type |
---|---|
T | extends keyof Methods |
Parametersβ
Name | Type |
---|---|
method | T |
params? | Methods [T ][``"params"``] |
Returnsβ
Promise
<Methods
[T
][``"result"``]>
Defined inβ
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β
getBlockHashAndNumberβ
βΈ getBlockHashAndNumber(): Promise
<BlockHashAndNumber
>
Returnsβ
Promise
<BlockHashAndNumber
>
Defined inβ
getBlockWithTxHashesβ
βΈ getBlockWithTxHashes(blockIdentifier?
): Promise
<BlockWithTxHashes
>
Parametersβ
Name | Type |
---|---|
blockIdentifier | BlockIdentifier |
Returnsβ
Promise
<BlockWithTxHashes
>
Defined inβ
getBlockWithTxsβ
βΈ getBlockWithTxs(blockIdentifier?
): Promise
<BlockWithTxs
>
Parametersβ
Name | Type |
---|---|
blockIdentifier | BlockIdentifier |
Returnsβ
Promise
<BlockWithTxs
>
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β
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β
getPendingTransactionsβ
βΈ getPendingTransactions(): Promise
<PendingTransactions
>
Returnsβ
Promise
<PendingTransactions
>
Defined inβ
getProtocolVersionβ
βΈ getProtocolVersion(): Promise
<Error
>
Returnsβ
Promise
<Error
>
Defined inβ
getStateUpdateβ
βΈ getStateUpdate(blockIdentifier?
): Promise
<StateUpdate
>
Gets the state changes in a specific block
Parametersβ
Name | Type | Description |
---|---|---|
blockIdentifier | BlockIdentifier | block identifier |
Returnsβ
Promise
<StateUpdate
>
StateUpdateResponse
Implementation ofβ
ProviderInterface.getStateUpdate
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 | string |
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β
getTransactionByHashβ
βΈ getTransactionByHash(txHash
): Promise
<TXN
>
Parametersβ
Name | Type |
---|---|
txHash | string |
Returnsβ
Promise
<TXN
>
Defined inβ
getTransactionByBlockIdAndIndexβ
βΈ getTransactionByBlockIdAndIndex(blockIdentifier
, index
): Promise
<TXN
>
Parametersβ
Name | Type |
---|---|
blockIdentifier | BlockIdentifier |
index | number |
Returnsβ
Promise
<TXN
>
Defined inβ
getTransactionReceiptβ
βΈ getTransactionReceipt(txHash
): Promise
<TXN_RECEIPT
>
Gets the transaction receipt from a tx hash.
Parametersβ
Name | Type |
---|---|
txHash | string |
Returnsβ
Promise
<TXN_RECEIPT
>
the transaction receipt object
Implementation ofβ
ProviderInterface.getTransactionReceipt
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β
getClassβ
βΈ getClass(classHash
, blockIdentifier?
): Promise
<ContractClassResponse
>
Parametersβ
Name | Type |
---|---|
classHash | string |
blockIdentifier | BlockIdentifier |
Returnsβ
Promise
<ContractClassResponse
>
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β
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β
getEstimateFeeβ
βΈ getEstimateFee(invocation
, 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 |
---|---|---|
invocation | 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(invocation
, invocationDetails
, blockIdentifier?
): Promise
<EstimateFeeResponse
>
Estimates the fee for a given INVOKE transaction
Parametersβ
Name | Type | Description |
---|---|---|
invocation | 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.getInvokeEstimateFee
Defined inβ
getDeclareEstimateFeeβ
βΈ getDeclareEstimateFee(invocation
, details
, blockIdentifier?
): Promise
<EstimateFeeResponse
>
Estimates the fee for a given DECLARE transaction
Parametersβ
Name | Type | Description |
---|---|---|
invocation | 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 |
Returnsβ
Promise
<EstimateFeeResponse
>
the estimated fee
Implementation ofβ
ProviderInterface.getDeclareEstimateFee
Defined inβ
getDeployAccountEstimateFeeβ
βΈ getDeployAccountEstimateFee(invocation
, details
, blockIdentifier?
): Promise
<EstimateFeeResponse
>
Estimates the fee for a given DEPLOY_ACCOUNT transaction
Parametersβ
Name | Type | Description |
---|---|---|
invocation | 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 |
Returnsβ
Promise
<EstimateFeeResponse
>
the estimated fee
Implementation ofβ
ProviderInterface.getDeployAccountEstimateFee
Defined inβ
getEstimateFeeBulkβ
βΈ getEstimateFeeBulk(invocations
, Β«destructuredΒ»
): Promise
<EstimateFeeResponseBulk
>
Estimates the fee for a list of INVOKE transaction
Parametersβ
Name | Type | Description |
---|---|---|
invocations | AccountInvocations | AccountInvocations - Complete invocations array with account details |
Β«destructuredΒ» | getEstimateFeeBulkOptions | getEstimateFeeBulkOptions - (optional) blockIdentifier - BlockIdentifier - (optional) skipValidate - boolean (default false) |
Returnsβ
Promise
<EstimateFeeResponseBulk
>
the estimated fee
Implementation ofβ
ProviderInterface.getEstimateFeeBulk
Defined inβ
declareContractβ
βΈ declareContract(Β«destructuredΒ»
, details
): Promise
<DeclareContractResponse
>
Declares a given compiled contract (json) to starknet
Parametersβ
Name | Type | Description |
---|---|---|
Β«destructuredΒ» | 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β
deployAccountContractβ
βΈ deployAccountContract(Β«destructuredΒ»
, details
): Promise
<DeployContractResponse
>
Deploys a given compiled Account contract (json) to starknet
Parametersβ
Name | Type | Description |
---|---|---|
Β«destructuredΒ» | 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β
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β
callContractβ
βΈ callContract(call
, blockIdentifier?
): Promise
<CallContractResponse
>
Calls a function on the Starknet contract.
Parametersβ
Name | Type | Description |
---|---|---|
call | 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β
traceTransactionβ
βΈ traceTransaction(transactionHash
): Promise
<TRANSACTION_TRACE
>
Parametersβ
Name | Type |
---|---|
transactionHash | string |
Returnsβ
Promise
<TRANSACTION_TRACE
>
Defined inβ
traceBlockTransactionsβ
βΈ traceBlockTransactions(blockHash
): Promise
<Traces
>
Parametersβ
Name | Type |
---|---|
blockHash | string |
Returnsβ
Promise
<Traces
>
Defined inβ
waitForTransactionβ
βΈ waitForTransaction(txHash
, options?
): Promise
<any
>
Wait for the transaction to be accepted
Parametersβ
Name | Type | Description |
---|---|---|
txHash | string | transaction hash |
options? | waitForTransactionOptions | waitForTransactionOptions - (optional) retryInterval: number | undefined; - (optional) successStates: TransactionStatus[] | undefined; |
Returnsβ
Promise
<any
>
GetTransactionReceiptResponse
Implementation ofβ
ProviderInterface.waitForTransaction
Defined inβ
getTransactionCountβ
βΈ getTransactionCount(blockIdentifier?
): Promise
<number
>
Gets the transaction count from a block.
Parametersβ
Name | Type |
---|---|
blockIdentifier | BlockIdentifier |
Returnsβ
Promise
<number
>
Number of transactions
Defined inβ
getBlockNumberβ
βΈ getBlockNumber(): Promise
<number
>
Gets the latest block number
Returnsβ
Promise
<number
>
Number of the latest block
Defined inβ
getSyncingStatsβ
βΈ getSyncingStats(): Promise
<SyncingStatus
>
Gets syncing status of the node
Returnsβ
Promise
<SyncingStatus
>
Object with the stats data
Defined inβ
getEventsβ
βΈ getEvents(eventFilter
): Promise
<EVENTS_CHUNK
>
Gets all the events filtered
Parametersβ
Name | Type |
---|---|
eventFilter | EventFilter |
Returnsβ
Promise
<EVENTS_CHUNK
>
events and the pagination of the events
Defined inβ
getSimulateTransactionβ
βΈ getSimulateTransaction(invocations
, Β«destructuredΒ»
): 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 |
Β«destructuredΒ» | 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β
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
>
Defined inβ
buildTransactionβ
βΈ buildTransaction(invocation
, versionType?
): BROADCASTED_TXN
Parametersβ
Name | Type |
---|---|
invocation | AccountInvocationItem |
versionType? | "fee" | "transaction" |
Returnsβ
BROADCASTED_TXN