Skip to main content
Version: 5.19.5

Class: RpcProvider

Implements​

Constructors​

constructor​

β€’ new RpcProvider(optionsOrProvider)

Parameters​

NameType
optionsOrProviderRpcProviderOptions

Defined in​

src/provider/rpc.ts:76

Properties​

nodeUrl​

β€’ nodeUrl: string

Defined in​

src/provider/rpc.ts:64


headers​

β€’ headers: object

Defined in​

src/provider/rpc.ts:66


responseParser​

β€’ Private responseParser: RPCResponseParser

Defined in​

src/provider/rpc.ts:68


retries​

β€’ Private retries: number

Defined in​

src/provider/rpc.ts:70


blockIdentifier​

β€’ Private blockIdentifier: BlockIdentifier

Defined in​

src/provider/rpc.ts:72


chainId​

β€’ Private Optional chainId: StarknetChainId

Defined in​

src/provider/rpc.ts:74

Methods​

fetch​

β–Έ fetch(method, params): Promise<any>

Parameters​

NameType
methodany
paramsany

Returns​

Promise<any>

Defined in​

src/provider/rpc.ts:86


errorHandler​

β–Έ Protected errorHandler(error): void

Parameters​

NameType
errorany

Returns​

void

Defined in​

src/provider/rpc.ts:95


fetchEndpoint​

β–Έ Protected fetchEndpoint<T>(method, params?): Promise<Methods[T][``"result"``]>

Type parameters​

NameType
Textends keyof Methods

Parameters​

NameType
methodT
params?Methods[T][``"params"``]

Returns​

Promise<Methods[T][``"result"``]>

Defined in​

src/provider/rpc.ts:102


getChainId​

β–Έ getChainId(): Promise<StarknetChainId>

Gets the Starknet chain Id

Returns​

Promise<StarknetChainId>

the chain Id

Implementation of​

ProviderInterface.getChainId

Defined in​

src/provider/rpc.ts:118


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/rpc.ts:123


getBlockHashAndNumber​

β–Έ getBlockHashAndNumber(): Promise<BlockHashAndNumber>

Returns​

Promise<BlockHashAndNumber>

Defined in​

src/provider/rpc.ts:131


getBlockWithTxHashes​

β–Έ getBlockWithTxHashes(blockIdentifier?): Promise<BlockWithTxHashes>

Parameters​

NameType
blockIdentifierBlockIdentifier

Returns​

Promise<BlockWithTxHashes>

Defined in​

src/provider/rpc.ts:135


getBlockWithTxs​

β–Έ getBlockWithTxs(blockIdentifier?): Promise<BlockWithTxs>

Parameters​

NameType
blockIdentifierBlockIdentifier

Returns​

Promise<BlockWithTxs>

Defined in​

src/provider/rpc.ts:142


getClassHashAt​

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

Returns the class hash deployed under the given address.

Parameters​

NameTypeDescription
contractAddressstringcontract address
blockIdentifierBlockIdentifierblock identifier

Returns​

Promise<string>

Class hash

Implementation of​

ProviderInterface.getClassHashAt

Defined in​

src/provider/rpc.ts:149


getNonceForAddress​

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

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

Parameters​

NameTypeDescription
contractAddressstringcontract address
blockIdentifierBlockIdentifier-

Returns​

Promise<string>

the hex nonce

Implementation of​

ProviderInterface.getNonceForAddress

Defined in​

src/provider/rpc.ts:160


getPendingTransactions​

β–Έ getPendingTransactions(): Promise<PendingTransactions>

Returns​

Promise<PendingTransactions>

Defined in​

src/provider/rpc.ts:171


getProtocolVersion​

β–Έ getProtocolVersion(): Promise<Error>

Returns​

Promise<Error>

Defined in​

src/provider/rpc.ts:175


getStateUpdate​

β–Έ getStateUpdate(blockIdentifier?): Promise<StateUpdate>

Gets the state changes in a specific block

Parameters​

NameTypeDescription
blockIdentifierBlockIdentifierblock identifier

Returns​

Promise<StateUpdate>

StateUpdateResponse

Implementation of​

ProviderInterface.getStateUpdate

Defined in​

src/provider/rpc.ts:179


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)
blockIdentifierBlockIdentifierblock identifier

Returns​

Promise<string>

the value of the storage variable

Implementation of​

ProviderInterface.getStorageAt

Defined in​

src/provider/rpc.ts:186


getTransaction​

β–Έ getTransaction(txHash): Promise<GetTransactionResponse>

Gets the transaction information from a tx id.

Parameters​

NameType
txHashstring

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/rpc.ts:201


getTransactionByHash​

β–Έ getTransactionByHash(txHash): Promise<TXN>

Parameters​

NameType
txHashstring

Returns​

Promise<TXN>

Defined in​

src/provider/rpc.ts:205


getTransactionByBlockIdAndIndex​

β–Έ getTransactionByBlockIdAndIndex(blockIdentifier, index): Promise<TXN>

Parameters​

NameType
blockIdentifierBlockIdentifier
indexnumber

Returns​

Promise<TXN>

Defined in​

src/provider/rpc.ts:209


getTransactionReceipt​

β–Έ getTransactionReceipt(txHash): Promise<TXN_RECEIPT>

Gets the transaction receipt from a tx hash.

Parameters​

NameType
txHashstring

Returns​

Promise<TXN_RECEIPT>

the transaction receipt object

Implementation of​

ProviderInterface.getTransactionReceipt

Defined in​

src/provider/rpc.ts:217


getClassByHash​

β–Έ getClassByHash(classHash): Promise<ContractClassResponse>

Returns the contract class deployed under the given class hash.

Parameters​

NameTypeDescription
classHashstringclass hash

Returns​

Promise<ContractClassResponse>

Contract class of compiled contract

Implementation of​

ProviderInterface.getClassByHash

Defined in​

src/provider/rpc.ts:221


getClass​

β–Έ getClass(classHash, blockIdentifier?): Promise<ContractClassResponse>

Parameters​

NameType
classHashstring
blockIdentifierBlockIdentifier

Returns​

Promise<ContractClassResponse>

Defined in​

src/provider/rpc.ts:225


getClassAt​

β–Έ getClassAt(contractAddress, blockIdentifier?): Promise<ContractClassResponse>

Gets the contract class of the deployed contract.

Parameters​

NameTypeDescription
contractAddressstringcontract address
blockIdentifierBlockIdentifierblock identifier

Returns​

Promise<ContractClassResponse>

Contract class of compiled contract

Implementation of​

ProviderInterface.getClassAt

Defined in​

src/provider/rpc.ts:236


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/rpc.ts:247


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​

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
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/rpc.ts:254


getInvokeEstimateFee​

β–Έ getInvokeEstimateFee(invocation, invocationDetails, blockIdentifier?): Promise<EstimateFeeResponse>

Estimates the fee for a given INVOKE transaction

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

Returns​

Promise<EstimateFeeResponse>

the estimated fee

Implementation of​

ProviderInterface.getInvokeEstimateFee

Defined in​

src/provider/rpc.ts:262


getDeclareEstimateFee​

β–Έ getDeclareEstimateFee(invocation, details, blockIdentifier?): Promise<EstimateFeeResponse>

Estimates the fee for a given DECLARE transaction

Parameters​

NameTypeDescription
invocationDeclareContractTransactiontransaction payload to be declared containing: - compiled contract code - sender address - signature - (defaults to []) the signature
detailsInvocationsDetailsWithNonceoptional details containing: - nonce - version - optional version - optional maxFee
blockIdentifierBlockIdentifier(optional) block identifier

Returns​

Promise<EstimateFeeResponse>

the estimated fee

Implementation of​

ProviderInterface.getDeclareEstimateFee

Defined in​

src/provider/rpc.ts:282


getDeployAccountEstimateFee​

β–Έ getDeployAccountEstimateFee(invocation, details, blockIdentifier?): Promise<EstimateFeeResponse>

Estimates the fee for a given DEPLOY_ACCOUNT transaction

Parameters​

NameTypeDescription
invocationDeployAccountContractTransactiontransaction payload to be deployed containing: - classHash - constructorCalldata - addressSalt - signature - (defaults to []) the signature
detailsInvocationsDetailsWithNonceoptional details containing: - nonce - version - optional version - optional maxFee
blockIdentifierBlockIdentifier(optional) block identifier

Returns​

Promise<EstimateFeeResponse>

the estimated fee

Implementation of​

ProviderInterface.getDeployAccountEstimateFee

Defined in​

src/provider/rpc.ts:302


getEstimateFeeBulk​

β–Έ getEstimateFeeBulk(invocations, Β«destructuredΒ»): Promise<EstimateFeeResponseBulk>

Estimates the fee for a list of INVOKE transaction

Parameters​

NameTypeDescription
invocationsAccountInvocationsAccountInvocations - Complete invocations array with account details
Β«destructuredΒ»getEstimateFeeBulkOptionsgetEstimateFeeBulkOptions - (optional) blockIdentifier - BlockIdentifier - (optional) skipValidate - boolean (default false)

Returns​

Promise<EstimateFeeResponseBulk>

the estimated fee

Implementation of​

ProviderInterface.getEstimateFeeBulk

Defined in​

src/provider/rpc.ts:322


declareContract​

β–Έ declareContract(Β«destructuredΒ», details): Promise<DeclareContractResponse>

Declares a given compiled contract (json) to starknet

Parameters​

NameTypeDescription
Β«destructuredΒ»DeclareContractTransactiontransaction 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/rpc.ts:337


deployAccountContract​

β–Έ deployAccountContract(Β«destructuredΒ», details): Promise<DeployContractResponse>

Deploys a given compiled Account contract (json) to starknet

Parameters​

NameTypeDescription
Β«destructuredΒ»DeployAccountContractTransactionpayload 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/rpc.ts:377


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​

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/rpc.ts:395


callContract​

β–Έ callContract(call, blockIdentifier?): Promise<CallContractResponse>

Calls a function on the Starknet contract.

Parameters​

NameTypeDescription
callCalltransaction to be called
blockIdentifierBlockIdentifierblock identifier

Returns​

Promise<CallContractResponse>

the result of the function on the smart contract.

Implementation of​

ProviderInterface.callContract

Defined in​

src/provider/rpc.ts:413


traceTransaction​

β–Έ traceTransaction(transactionHash): Promise<TRANSACTION_TRACE>

Parameters​

NameType
transactionHashstring

Returns​

Promise<TRANSACTION_TRACE>

Defined in​

src/provider/rpc.ts:430


traceBlockTransactions​

β–Έ traceBlockTransactions(blockHash): Promise<Traces>

Parameters​

NameType
blockHashstring

Returns​

Promise<Traces>

Defined in​

src/provider/rpc.ts:434


waitForTransaction​

β–Έ waitForTransaction(txHash, options?): Promise<any>

Wait for the transaction to be accepted

Parameters​

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

Returns​

Promise<any>

GetTransactionReceiptResponse

Implementation of​

ProviderInterface.waitForTransaction

Defined in​

src/provider/rpc.ts:438


getTransactionCount​

β–Έ getTransactionCount(blockIdentifier?): Promise<number>

Gets the transaction count from a block.

Parameters​

NameType
blockIdentifierBlockIdentifier

Returns​

Promise<number>

Number of transactions

Defined in​

src/provider/rpc.ts:503


getBlockNumber​

β–Έ getBlockNumber(): Promise<number>

Gets the latest block number

Returns​

Promise<number>

Number of the latest block

Defined in​

src/provider/rpc.ts:516


getSyncingStats​

β–Έ getSyncingStats(): Promise<SyncingStatus>

Gets syncing status of the node

Returns​

Promise<SyncingStatus>

Object with the stats data

Defined in​

src/provider/rpc.ts:526


getEvents​

β–Έ getEvents(eventFilter): Promise<EVENTS_CHUNK>

Gets all the events filtered

Parameters​

NameType
eventFilterEventFilter

Returns​

Promise<EVENTS_CHUNK>

events and the pagination of the events

Defined in​

src/provider/rpc.ts:536


getSimulateTransaction​

β–Έ getSimulateTransaction(invocations, Β«destructuredΒ»): Promise<SimulateTransactionResponse>

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

Parameters​

NameTypeDescription
invocationsAccountInvocationsAccountInvocations - Complete invocations array with account details
Β«destructuredΒ»getSimulateTransactionOptionsgetSimulateTransactionOptions - (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​

src/provider/rpc.ts:540


getStarkName​

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

Parameters​

NameType
addressBigNumberish
StarknetIdContract?string

Returns​

Promise<string>

Defined in​

src/provider/rpc.ts:562


getAddressFromStarkName​

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

Parameters​

NameType
namestring
StarknetIdContract?string

Returns​

Promise<string>

Defined in​

src/provider/rpc.ts:566


buildTransaction​

β–Έ buildTransaction(invocation, versionType?): BaseTransaction

Parameters​

NameType
invocationAccountInvocationItem
versionType?"fee" | "transaction"

Returns​

BaseTransaction

Defined in​

src/provider/rpc.ts:570