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β
getBlockHashAndNumberβ
β’ getBlockHashAndNumber: () => Promise
<BlockHashAndNumber
>
Type declarationβ
βΈ (): Promise
<BlockHashAndNumber
>
Deprecated
renamed to getBlockLatestAccepted(); (will be removed in next minor version)
Returnsβ
Promise
<BlockHashAndNumber
>
Defined inβ
getStateUpdateβ
β’ getStateUpdate: (blockIdentifier
: BlockIdentifier
) => Promise
<PENDING_STATE_UPDATE
| STATE_UPDATE
>
Type declarationβ
βΈ (blockIdentifier?
): Promise
<PENDING_STATE_UPDATE
| STATE_UPDATE
>
Deprecated
renamed to getBlockStateUpdate();
Parametersβ
Name | Type |
---|---|
blockIdentifier | BlockIdentifier |
Returnsβ
Promise
<PENDING_STATE_UPDATE
| STATE_UPDATE
>
Implementation ofβ
ProviderInterface.getStateUpdate
Defined inβ
traceBlockTransactionsβ
β’ traceBlockTransactions: (blockIdentifier
: BlockIdentifier
) => Promise
<BlockTransactionsTraces
>
Type declarationβ
βΈ (blockIdentifier?
): Promise
<BlockTransactionsTraces
>
Returns the execution traces of all transactions included in the given block
Deprecated
renamed to getBlockTransactionsTraces()
Parametersβ
Name | Type |
---|---|
blockIdentifier | BlockIdentifier |
Returnsβ
Promise
<BlockTransactionsTraces
>
Defined inβ
getTransactionCountβ
β’ getTransactionCount: (blockIdentifier
: BlockIdentifier
) => Promise
<number
>
Type declarationβ
βΈ (blockIdentifier?
): Promise
<number
>
Get the number of transactions in a block given a block id
Deprecated
renamed to getBlockTransactionCount()
Parametersβ
Name | Type |
---|---|
blockIdentifier | BlockIdentifier |
Returnsβ
Promise
<number
>
Number of transactions
Defined inβ
traceTransactionβ
β’ traceTransaction: (txHash
: BigNumberish
) => Promise
<TRANSACTION_TRACE
>
Type declarationβ
βΈ (txHash
): Promise
<TRANSACTION_TRACE
>
Deprecated
renamed to getTransactionTrace(); For a given executed transaction, return the trace of its execution, including internal calls
Parametersβ
Name | Type |
---|---|
txHash | BigNumberish |
Returnsβ
Promise
<TRANSACTION_TRACE
>
Defined inβ
getSimulateTransactionβ
β’ getSimulateTransaction: (invocations
: AccountInvocations
, __namedParameters
: getSimulateTransactionOptions
) => Promise
<SimulateTransactionResponse
>
Type declarationβ
βΈ (invocations
, Β«destructuredΒ»
): Promise
<SimulateTransactionResponse
>
Deprecated
renamed to simulateTransaction();
Parametersβ
Name | Type |
---|---|
invocations | AccountInvocations |
Β«destructuredΒ» | getSimulateTransactionOptions |
Returnsβ
Promise
<SimulateTransactionResponse
>
Implementation ofβ
ProviderInterface.getSimulateTransaction
Defined inβ
Methodsβ
fetchβ
βΈ fetch(method
, params?
, id?
): Promise
<Response
>
Parametersβ
Name | Type | Default value |
---|---|---|
method | string | undefined |
params? | object | undefined |
id | string | number | 0 |
Returnsβ
Promise
<Response
>
Defined inβ
errorHandlerβ
βΈ Protected
errorHandler(method
, params
, rpcError?
, otherError?
): void
Parametersβ
Name | Type |
---|---|
method | string |
params | any |
rpcError? | Error |
otherError? | any |
Returnsβ
void
Defined inβ
fetchEndpointβ
βΈ Protected
fetchEndpoint<T
>(method
, params?
): Promise
<Methods
[T
][``"result"``]>
Type parametersβ
Name | Type |
---|---|
T | extends keyof ReadMethods | keyof WriteMethods | keyof TraceMethods |
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β
getSpecVersionβ
βΈ getSpecVersion(): Promise
<string
>
NEW: Returns the version of the Starknet JSON-RPC specification being used
Returnsβ
Promise
<string
>
Defined inβ
getNonceForAddressβ
βΈ getNonceForAddress(contractAddress
, blockIdentifier?
): Promise
<string
>
Returns the nonce associated with the given address in the given block
Parametersβ
Name | Type | Description |
---|---|---|
contractAddress | BigNumberish | contract address |
blockIdentifier | BlockIdentifier | - |
Returnsβ
Promise
<string
>
the hex nonce
Implementation ofβ
ProviderInterface.getNonceForAddress
Defined inβ
getBlockβ
βΈ getBlock(blockIdentifier?
): Promise
<GetBlockResponse
>
Deprecated
use getBlockWithTxHashes or getBlockWithTxs (will be removed on sequencer deprecation)
Parametersβ
Name | Type |
---|---|
blockIdentifier | BlockIdentifier |
Returnsβ
Promise
<GetBlockResponse
>
Implementation ofβ
Defined inβ
getBlockLatestAcceptedβ
βΈ getBlockLatestAccepted(): Promise
<BlockHashAndNumber
>
Get the most recent accepted block hash and number
Returnsβ
Promise
<BlockHashAndNumber
>
Defined inβ
getBlockNumberβ
βΈ getBlockNumber(): Promise
<number
>
Deprecated
redundant use getBlockLatestAccepted(); Get the most recent accepted block number
Returnsβ
Promise
<number
>
Number of the latest block
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β
getBlockStateUpdateβ
βΈ getBlockStateUpdate(blockIdentifier?
): Promise
<PENDING_STATE_UPDATE
| STATE_UPDATE
>
Parametersβ
Name | Type |
---|---|
blockIdentifier | BlockIdentifier |
Returnsβ
Promise
<PENDING_STATE_UPDATE
| STATE_UPDATE
>
Defined inβ
getBlockTransactionsTracesβ
βΈ getBlockTransactionsTraces(blockIdentifier?
): Promise
<BlockTransactionsTraces
>
Parametersβ
Name | Type |
---|---|
blockIdentifier | BlockIdentifier |
Returnsβ
Promise
<BlockTransactionsTraces
>
Defined inβ
getBlockTransactionCountβ
βΈ getBlockTransactionCount(blockIdentifier?
): Promise
<number
>
Parametersβ
Name | Type |
---|---|
blockIdentifier | BlockIdentifier |
Returnsβ
Promise
<number
>
Defined inβ
getPendingTransactionsβ
βΈ getPendingTransactions(): Promise
<TransactionWithHash
[]>
Return transactions from pending block
Deprecated
Instead use getBlock(BlockTag.pending); (will be removed in next minor version)
Returnsβ
Promise
<TransactionWithHash
[]>
Defined inβ
getTransactionβ
βΈ getTransaction(txHash
): Promise
<InvokeTransactionResponse
| DeclareTransactionResponse
| RejectedTransactionResponse
>
Deprecated
use getTransactionByHash or getTransactionByBlockIdAndIndex (will be removed on sequencer deprecation)
Parametersβ
Name | Type |
---|---|
txHash | BigNumberish |
Returnsβ
Promise
<InvokeTransactionResponse
| DeclareTransactionResponse
| RejectedTransactionResponse
>
Implementation ofβ
ProviderInterface.getTransaction
Defined inβ
getTransactionByHashβ
βΈ getTransactionByHash(txHash
): Promise
<TransactionWithHash
>
Parametersβ
Name | Type |
---|---|
txHash | BigNumberish |
Returnsβ
Promise
<TransactionWithHash
>
Defined inβ
getTransactionByBlockIdAndIndexβ
βΈ getTransactionByBlockIdAndIndex(blockIdentifier
, index
): Promise
<TransactionWithHash
>
Parametersβ
Name | Type |
---|---|
blockIdentifier | BlockIdentifier |
index | number |
Returnsβ
Promise
<TransactionWithHash
>
Defined inβ
getTransactionReceiptβ
βΈ getTransactionReceipt(txHash
): Promise
<TransactionReceipt
>
Gets the transaction receipt from a tx hash.
Parametersβ
Name | Type |
---|---|
txHash | BigNumberish |
Returnsβ
Promise
<TransactionReceipt
>
the transaction receipt object
Implementation ofβ
ProviderInterface.getTransactionReceipt
Defined inβ
getTransactionTraceβ
βΈ getTransactionTrace(txHash
): Promise
<TRANSACTION_TRACE
>
Parametersβ
Name | Type |
---|---|
txHash | BigNumberish |
Returnsβ
Promise
<TRANSACTION_TRACE
>
Defined inβ
getTransactionStatusβ
βΈ getTransactionStatus(transactionHash
): Promise
<TransactionStatus
>
NEW: Get the status of a transaction
Parametersβ
Name | Type |
---|---|
transactionHash | BigNumberish |
Returnsβ
Promise
<TransactionStatus
>
Defined inβ
simulateTransactionβ
βΈ simulateTransaction(invocations
, simulateTransactionOptions
): Promise
<SimulateTransactionResponse
>
Parametersβ
Name | Type | Description |
---|---|---|
invocations | AccountInvocations | AccountInvocations |
simulateTransactionOptions | getSimulateTransactionOptions | blockIdentifier and flags to skip validation and fee charge - blockIdentifier - skipValidate (default false) - skipFeeCharge (default true) |
Returnsβ
Promise
<SimulateTransactionResponse
>
Defined inβ
waitForTransactionβ
βΈ waitForTransaction(txHash
, options?
): Promise
<TransactionReceipt
>
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
<TransactionReceipt
>
GetTransactionReceiptResponse
Implementation ofβ
ProviderInterface.waitForTransaction
Defined inβ
getStorageAtβ
βΈ getStorageAt(contractAddress
, key
, blockIdentifier?
): Promise
<string
>
Get the value of the storage (contract's variable) at the given address and key
Parametersβ
Name | Type | Description |
---|---|---|
contractAddress | BigNumberish | |
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β
getClassHashAtβ
βΈ getClassHashAt(contractAddress
, blockIdentifier?
): Promise
<string
>
Returns the contract class hash in the given block for the contract deployed at the given address
Parametersβ
Name | Type | Description |
---|---|---|
contractAddress | BigNumberish | contract address |
blockIdentifier | BlockIdentifier | block identifier |
Returnsβ
Promise
<string
>
Class hash
Implementation ofβ
ProviderInterface.getClassHashAt
Defined inβ
getClassByHashβ
βΈ getClassByHash(classHash
): Promise
<LegacyContractClass
| Omit
<CompiledSierra
, "sierra_program_debug_info"
>>
Returns the contract class deployed under the given class hash.
Parametersβ
Name | Type | Description |
---|---|---|
classHash | BigNumberish | class hash |
Returnsβ
Promise
<LegacyContractClass
| Omit
<CompiledSierra
, "sierra_program_debug_info"
>>
Contract class of compiled contract
Implementation ofβ
ProviderInterface.getClassByHash
Defined inβ
getClassβ
βΈ getClass(classHash
, blockIdentifier?
): Promise
<LegacyContractClass
| Omit
<CompiledSierra
, "sierra_program_debug_info"
>>
Parametersβ
Name | Type |
---|---|
classHash | BigNumberish |
blockIdentifier | BlockIdentifier |
Returnsβ
Promise
<LegacyContractClass
| Omit
<CompiledSierra
, "sierra_program_debug_info"
>>
Defined inβ
getClassAtβ
βΈ getClassAt(contractAddress
, blockIdentifier?
): Promise
<LegacyContractClass
| Omit
<CompiledSierra
, "sierra_program_debug_info"
>>
Gets the contract class of the deployed contract.
Parametersβ
Name | Type | Description |
---|---|---|
contractAddress | BigNumberish | contract address |
blockIdentifier | BlockIdentifier | block identifier |
Returnsβ
Promise
<LegacyContractClass
| Omit
<CompiledSierra
, "sierra_program_debug_info"
>>
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β
getContractVersionβ
βΈ getContractVersion(contractAddress
, classHash?
, options?
): Promise
<ContractVersion
>
Gets the contract version from the provided address
Parametersβ
Name | Type | Description |
---|---|---|
contractAddress | BigNumberish | string |
classHash? | undefined | undefined |
options? | getContractVersionOptions | getContractVersionOptions - (optional) compiler - (default true) extract compiler version using type tactic from abi - (optional) blockIdentifier - block identifier |
Returnsβ
Promise
<ContractVersion
>
Implementation ofβ
ProviderInterface.getContractVersion
Defined inβ
βΈ getContractVersion(contractAddress
, classHash
, options?
): Promise
<ContractVersion
>
Gets the contract version from the provided address
Parametersβ
Name | Type | Description |
---|---|---|
contractAddress | undefined | undefined |
classHash | BigNumberish | |
options? | getContractVersionOptions | getContractVersionOptions - (optional) compiler - (default true) extract compiler version using type tactic from abi - (optional) blockIdentifier - block identifier |
Returnsβ
Promise
<ContractVersion
>
Implementation ofβ
ProviderInterface.getContractVersion
Defined inβ
getEstimateFeeβ
βΈ getEstimateFee(invocation
, invocationDetails
, blockIdentifier?
): Promise
<EstimateFeeResponse
>
Deprecated
use gettypeEstimateFee (will be refactored based on type after sequencer deprecation)
Parametersβ
Name | Type |
---|---|
invocation | Invocation |
invocationDetails | InvocationsDetailsWithNonce |
blockIdentifier | BlockIdentifier |
Returnsβ
Promise
<EstimateFeeResponse
>
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β
invokeFunctionβ
βΈ invokeFunction(functionInvocation
, details
): Promise
<InvokedTransaction
>
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
<InvokedTransaction
>
response from addTransaction
Implementation ofβ
ProviderInterface.invokeFunction
Defined inβ
declareContractβ
βΈ declareContract(Β«destructuredΒ»
, details
): Promise
<DeclaredTransaction
>
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
<DeclaredTransaction
>
a confirmation of sending a transaction on the starknet contract
Implementation ofβ
ProviderInterface.declareContract
Defined inβ
deployAccountContractβ
βΈ deployAccountContract(Β«destructuredΒ»
, details
): Promise
<DeployedAccountTransaction
>
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
<DeployedAccountTransaction
>
a confirmation of sending a transaction on the starknet contract
Implementation ofβ
ProviderInterface.deployAccountContract
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β
estimateMessageFeeβ
βΈ estimateMessageFee(message
, blockIdentifier?
): Promise
<FEE_ESTIMATE
>
NEW: Estimate the fee for a message from L1
Parametersβ
Name | Type | Description |
---|---|---|
message | MSG_FROM_L1 | Message From L1 |
blockIdentifier | BlockIdentifier | - |
Returnsβ
Promise
<FEE_ESTIMATE
>
Defined inβ
getSyncingStatsβ
βΈ getSyncingStats(): Promise
<Syncing
>
Returns an object about the sync status, or false if the node is not synching
Returnsβ
Promise
<Syncing
>
Object with the stats data
Defined inβ
getEventsβ
βΈ getEvents(eventFilter
): Promise
<EVENTS_CHUNK
>
Returns all events matching the given filter
Parametersβ
Name | Type |
---|---|
eventFilter | EventFilter |
Returnsβ
Promise
<EVENTS_CHUNK
>
events and the pagination of the events
Defined inβ
getStarkNameβ
βΈ getStarkName(address
, StarknetIdContract?
): Promise
<string
>
StarknetId Endpoint (get name from address)
Parametersβ
Name | Type |
---|---|
address | BigNumberish |
StarknetIdContract? | string |
Returnsβ
Promise
<string
>
Defined inβ
getAddressFromStarkNameβ
βΈ getAddressFromStarkName(name
, StarknetIdContract?
): Promise
<string
>
StarknetId Endpoint (get address from name)
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" |