Skip to main content
Version: Next

Class: RpcProvider

Defined in: src/provider/rpc.ts:63

Extends

Implements

Constructors

Constructor

new RpcProvider(optionsOrProvider?): RpcProvider

Defined in: src/provider/rpc.ts:71

Parameters

optionsOrProvider?

RpcProviderOptions | ProviderInterface | RpcProvider

Returns

RpcProvider

Properties

responseParser

responseParser: RPCResponseParser

Defined in: src/provider/rpc.ts:64

Implementation of

ProviderInterface.responseParser


channel

channel: RpcChannel | RpcChannel | RpcChannel

Defined in: src/provider/rpc.ts:66

Implementation of

ProviderInterface.channel


pluginManager

readonly pluginManager: PluginManager

Defined in: src/provider/rpc.ts:69

Internal

Plugin management infrastructure


getStateUpdate

getStateUpdate: {(): Promise<{ block_hash: string; new_root: string; old_root: string; state_diff: { storage_diffs: object[]; deprecated_declared_classes: string[]; declared_classes: object[]; deployed_contracts: object[]; replaced_classes: object[]; nonces: object[]; migrated_compiled_classes?: object[]; }; }>; (blockIdentifier): Promise<{ block_hash: never; state_diff: { storage_diffs: object[]; deprecated_declared_classes: string[]; declared_classes: object[]; deployed_contracts: object[]; replaced_classes: object[]; nonces: object[]; migrated_compiled_classes?: object[]; }; old_root?: string; }>; (blockIdentifier): Promise<{ block_hash: string; new_root: string; old_root: string; state_diff: { storage_diffs: object[]; deprecated_declared_classes: string[]; declared_classes: object[]; deployed_contracts: object[]; replaced_classes: object[]; nonces: object[]; migrated_compiled_classes?: object[]; }; }>; (blockIdentifier?, contractAddresses?): Promise<StateUpdateResponse>; }

Defined in: src/provider/rpc.ts:319

Gets the state changes in a specific block (result of executing the requested block)

Call Signature

(): Promise<{ block_hash: string; new_root: string; old_root: string; state_diff: { storage_diffs: object[]; deprecated_declared_classes: string[]; declared_classes: object[]; deployed_contracts: object[]; replaced_classes: object[]; nonces: object[]; migrated_compiled_classes?: object[]; }; }>

Gets the state changes in a specific block (result of executing the requested block) Alternative method name for getStateUpdate with specific overloads

Returns

Promise<{ block_hash: string; new_root: string; old_root: string; state_diff: { storage_diffs: object[]; deprecated_declared_classes: string[]; declared_classes: object[]; deployed_contracts: object[]; replaced_classes: object[]; nonces: object[]; migrated_compiled_classes?: object[]; }; }>

StateUpdateResponse

Call Signature

(blockIdentifier): Promise<{ block_hash: never; state_diff: { storage_diffs: object[]; deprecated_declared_classes: string[]; declared_classes: object[]; deployed_contracts: object[]; replaced_classes: object[]; nonces: object[]; migrated_compiled_classes?: object[]; }; old_root?: string; }>

Parameters
blockIdentifier

"pre_confirmed"

Returns

Promise<{ block_hash: never; state_diff: { storage_diffs: object[]; deprecated_declared_classes: string[]; declared_classes: object[]; deployed_contracts: object[]; replaced_classes: object[]; nonces: object[]; migrated_compiled_classes?: object[]; }; old_root?: string; }>

Call Signature

(blockIdentifier): Promise<{ block_hash: string; new_root: string; old_root: string; state_diff: { storage_diffs: object[]; deprecated_declared_classes: string[]; declared_classes: object[]; deployed_contracts: object[]; replaced_classes: object[]; nonces: object[]; migrated_compiled_classes?: object[]; }; }>

Parameters
blockIdentifier

"latest"

Returns

Promise<{ block_hash: string; new_root: string; old_root: string; state_diff: { storage_diffs: object[]; deprecated_declared_classes: string[]; declared_classes: object[]; deployed_contracts: object[]; replaced_classes: object[]; nonces: object[]; migrated_compiled_classes?: object[]; }; }>

Call Signature

(blockIdentifier?, contractAddresses?): Promise<StateUpdateResponse>

Parameters
blockIdentifier?

BlockIdentifier

contractAddresses?

BigNumberish[]

Returns

Promise<StateUpdateResponse>

Param

block identifier

Returns

StateUpdateResponse

Implementation of

ProviderInterface.getStateUpdate

Methods

create()

static create<T>(this, optionsOrProvider?): Promise<T>

Defined in: src/provider/rpc.ts:119

auto configure channel based on provided node leave space for other async before constructor

Type Parameters

T

T extends RpcProvider

Parameters

this

(...args) => T

optionsOrProvider?

RpcProviderOptions

Returns

Promise<T>


use()

use<T>(plugin): RpcProvider & T

Defined in: src/provider/rpc.ts:159

Install a plugin at runtime. Returns the instance typed with plugin methods.

Type Parameters

T

T extends Record<string, any>

Parameters

plugin

StarknetPlugin<T, any>

Returns

RpcProvider & T

Example

const provider = new RpcProvider({ nodeUrl: '...' })
.use(myPlugin());
provider.myMethod(); // typed

fetch()

fetch(method, params?, id?): Promise<any>

Defined in: src/provider/rpc.ts:164

Direct RPC method call

Parameters

method

string

RPC method name

params?

object

method parameters

id?

string | number

request ID

Returns

Promise<any>

RPC response

Implementation of

ProviderInterface.fetch


getChainId()

getChainId(): Promise<"0x534e5f4d41494e" | "0x534e5f5345504f4c4941">

Defined in: src/provider/rpc.ts:182

Gets the Starknet chain Id

Returns

Promise<"0x534e5f4d41494e" | "0x534e5f5345504f4c4941">

the chain Id

Implementation of

ProviderInterface.getChainId


readSpecVersion()

readSpecVersion(): "0.9.0" | "0.10.0" | "0.10.2" | "0.10.3" | undefined

Defined in: src/provider/rpc.ts:186

Read channel spec version

Returns

"0.9.0" | "0.10.0" | "0.10.2" | "0.10.3" | undefined

Spec version string or undefined if not set

Implementation of

ProviderInterface.readSpecVersion


getSpecVersion()

getSpecVersion(): Promise<string>

Defined in: src/provider/rpc.ts:190

Get channel spec version

Returns

Promise<string>

Promise resolving to spec version

Implementation of

ProviderInterface.getSpecVersion


setUpSpecVersion()

setUpSpecVersion(): Promise<"0.9.0" | "0.10.0" | "0.10.2" | "0.10.3">

Defined in: src/provider/rpc.ts:194

Setup channel spec version and return it

Returns

Promise<"0.9.0" | "0.10.0" | "0.10.2" | "0.10.3">

Promise resolving to spec version

Implementation of

ProviderInterface.setUpSpecVersion


getStarknetVersion()

getStarknetVersion(blockIdentifier?): Promise<string>

Defined in: src/provider/rpc.ts:198

Parameters

blockIdentifier?

BlockIdentifier

Returns

Promise<string>


getNonceForAddress()

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

Defined in: src/provider/rpc.ts:202

Returns the nonce associated with the given address in the given block

Parameters

contractAddress

BigNumberish

contract address

blockIdentifier?

BlockIdentifier

Returns

Promise<string>

the hex nonce

Implementation of

ProviderInterface.getNonceForAddress


getBlock()

Call Signature

getBlock(): Promise<{ transactions: string[]; block_number: number; timestamp: number; sequencer_address: string; l1_gas_price: RESOURCE_PRICE; l2_gas_price: RESOURCE_PRICE; l1_data_gas_price: RESOURCE_PRICE; l1_da_mode: L1_DA_MODE; starknet_version: string; }>

Defined in: src/provider/rpc.ts:209

Gets the block information

Returns

Promise<{ transactions: string[]; block_number: number; timestamp: number; sequencer_address: string; l1_gas_price: RESOURCE_PRICE; l2_gas_price: RESOURCE_PRICE; l1_data_gas_price: RESOURCE_PRICE; l1_da_mode: L1_DA_MODE; starknet_version: string; }>

the block object

Implementation of

ProviderInterface.getBlock

Call Signature

getBlock(blockIdentifier): Promise<{ transactions: string[]; block_number: number; timestamp: number; sequencer_address: string; l1_gas_price: RESOURCE_PRICE; l2_gas_price: RESOURCE_PRICE; l1_data_gas_price: RESOURCE_PRICE; l1_da_mode: L1_DA_MODE; starknet_version: string; }>

Defined in: src/provider/rpc.ts:210

Gets the block information

Parameters
blockIdentifier

"pre_confirmed"

Returns

Promise<{ transactions: string[]; block_number: number; timestamp: number; sequencer_address: string; l1_gas_price: RESOURCE_PRICE; l2_gas_price: RESOURCE_PRICE; l1_data_gas_price: RESOURCE_PRICE; l1_da_mode: L1_DA_MODE; starknet_version: string; }>

the block object

Implementation of

ProviderInterface.getBlock

Call Signature

getBlock(blockIdentifier): Promise<{ status: EBlockStatus; block_hash: string; parent_hash: string; block_number: number; new_root: string; timestamp: number; sequencer_address: string; l1_gas_price: RESOURCE_PRICE; l2_gas_price: RESOURCE_PRICE; l1_data_gas_price: RESOURCE_PRICE; l1_da_mode: L1_DA_MODE; starknet_version: string; event_commitment: string; transaction_commitment: string; receipt_commitment: string; state_diff_commitment: string; event_count: number; transaction_count: number; state_diff_length: number; transactions: string[]; }>

Defined in: src/provider/rpc.ts:211

Gets the block information

Parameters
blockIdentifier

"latest"

Returns

Promise<{ status: EBlockStatus; block_hash: string; parent_hash: string; block_number: number; new_root: string; timestamp: number; sequencer_address: string; l1_gas_price: RESOURCE_PRICE; l2_gas_price: RESOURCE_PRICE; l1_data_gas_price: RESOURCE_PRICE; l1_da_mode: L1_DA_MODE; starknet_version: string; event_commitment: string; transaction_commitment: string; receipt_commitment: string; state_diff_commitment: string; event_count: number; transaction_count: number; state_diff_length: number; transactions: string[]; }>

the block object

Implementation of

ProviderInterface.getBlock

Call Signature

getBlock(blockIdentifier): Promise<GetBlockResponse>

Defined in: src/provider/rpc.ts:212

Gets the block information

Parameters
blockIdentifier

BlockIdentifier

Returns

Promise<GetBlockResponse>

the block object

Implementation of

ProviderInterface.getBlock


getBlockLatestAccepted()

getBlockLatestAccepted(): Promise<BlockHashAndNumber>

Defined in: src/provider/rpc.ts:219

Get the most recent accepted block hash and number

Returns

Promise<BlockHashAndNumber>

Object containing block hash and number

Implementation of

ProviderInterface.getBlockLatestAccepted


getBlockNumber()

getBlockNumber(): Promise<number>

Defined in: src/provider/rpc.ts:223

Get the most recent accepted block number

Returns

Promise<number>

Number of the latest block

Implementation of

ProviderInterface.getBlockNumber


getBlockWithTxHashes()

getBlockWithTxHashes(blockIdentifier?): Promise<OnlyFirst<BLOCK_WITH_TX_HASHES, object & BLOCK_HEADER & BLOCK_BODY_WITH_TX_HASHES & PRE_CONFIRMED_BLOCK_HEADER> | OnlyFirst<PRE_CONFIRMED_BLOCK_WITH_TX_HASHES, object & BLOCK_HEADER & BLOCK_BODY_WITH_TX_HASHES & PRE_CONFIRMED_BLOCK_HEADER>>

Defined in: src/provider/rpc.ts:227

Get block information with transaction hashes

Parameters

blockIdentifier?

BlockIdentifier

block identifier

Returns

Promise<OnlyFirst<BLOCK_WITH_TX_HASHES, object & BLOCK_HEADER & BLOCK_BODY_WITH_TX_HASHES & PRE_CONFIRMED_BLOCK_HEADER> | OnlyFirst<PRE_CONFIRMED_BLOCK_WITH_TX_HASHES, object & BLOCK_HEADER & BLOCK_BODY_WITH_TX_HASHES & PRE_CONFIRMED_BLOCK_HEADER>>

Block with transaction hashes

Implementation of

ProviderInterface.getBlockWithTxHashes


getBlockWithTxs()

getBlockWithTxs(blockIdentifier?, options?): Promise<OnlyFirst<BLOCK_WITH_TXS, object & BLOCK_HEADER & BLOCK_BODY_WITH_TXS & PRE_CONFIRMED_BLOCK_HEADER> | OnlyFirst<PRE_CONFIRMED_BLOCK_WITH_TXS, object & BLOCK_HEADER & BLOCK_BODY_WITH_TXS & PRE_CONFIRMED_BLOCK_HEADER>>

Defined in: src/provider/rpc.ts:231

Get block information with full transactions

Parameters

blockIdentifier?

BlockIdentifier

block identifier

options?

(optional) additional request options

  • includeProofFacts - include proof facts in the transaction response (RPC 0.10.1+)
includeProofFacts?

boolean

Returns

Promise<OnlyFirst<BLOCK_WITH_TXS, object & BLOCK_HEADER & BLOCK_BODY_WITH_TXS & PRE_CONFIRMED_BLOCK_HEADER> | OnlyFirst<PRE_CONFIRMED_BLOCK_WITH_TXS, object & BLOCK_HEADER & BLOCK_BODY_WITH_TXS & PRE_CONFIRMED_BLOCK_HEADER>>

Block with full transactions

Implementation of

ProviderInterface.getBlockWithTxs


waitForBlock()

waitForBlock(blockIdentifier?, retryInterval?): Promise<void>

Defined in: src/provider/rpc.ts:241

Pause execution until a specified block is created

Parameters

blockIdentifier?

BlockIdentifier = BlockTag.LATEST

block number or tag

retryInterval?

number = 5000

milliseconds between requests (default: 5000)

Returns

Promise<void>

Example

await provider.waitForBlock(12345);
await provider.waitForBlock('latest');

Implementation of

ProviderInterface.waitForBlock


getL1GasPrice()

getL1GasPrice(blockIdentifier?): Promise<string>

Defined in: src/provider/rpc.ts:271

Gets the price of l1 gas in the block

Parameters

blockIdentifier?

BlockIdentifier

block identifier

Returns

Promise<string>

gas price of the block

Implementation of

ProviderInterface.getL1GasPrice


getGasPrices()

getGasPrices(blockIdentifier?): Promise<GasPrices>

Defined in: src/provider/rpc.ts:287

Get the gas prices related to a block.

Parameters

blockIdentifier?

BlockIdentifier = ...

Returns

Promise<GasPrices>

an object with l1DataGasPrice, l1GasPrice, l2GasPrice properties (all bigint type).

Example

const result = await myProvider.getGasPrices();
// result = { l1DataGasPrice: 3039n, l1GasPrice: 55590341542890n, l2GasPrice: 8441845008n }

getL1MessageHash()

getL1MessageHash(l2TxHash): Promise<string>

Defined in: src/provider/rpc.ts:293

Get L1 message hash from L2 transaction hash

Parameters

l2TxHash

BigNumberish

L2 transaction hash

Returns

Promise<string>

Hex string of L1 message hash

Example

In Sepolia Testnet :

const result = provider.getL1MessageHash('0x28dfc05eb4f261b37ddad451ff22f1d08d4e3c24dc646af0ec69fa20e096819');
// result = '0x55b3f8b6e607fffd9b4d843dfe8f9b5c05822cd94fcad8797deb01d77805532a'

Implementation of

ProviderInterface.getL1MessageHash


getBlockWithReceipts()

getBlockWithReceipts(blockIdentifier?, options?): Promise<OnlyFirst<BLOCK_WITH_RECEIPTS, object & BLOCK_HEADER & BLOCK_BODY_WITH_RECEIPTS & PRE_CONFIRMED_BLOCK_HEADER> | OnlyFirst<PRE_CONFIRMED_BLOCK_WITH_RECEIPTS, object & BLOCK_HEADER & BLOCK_BODY_WITH_RECEIPTS & PRE_CONFIRMED_BLOCK_HEADER>>

Defined in: src/provider/rpc.ts:309

Get block information with transaction receipts

Parameters

blockIdentifier?

BlockIdentifier

block identifier

options?

(optional) additional request options

  • includeProofFacts - include proof facts in the transaction response (RPC 0.10.1+)
includeProofFacts?

boolean

Returns

Promise<OnlyFirst<BLOCK_WITH_RECEIPTS, object & BLOCK_HEADER & BLOCK_BODY_WITH_RECEIPTS & PRE_CONFIRMED_BLOCK_HEADER> | OnlyFirst<PRE_CONFIRMED_BLOCK_WITH_RECEIPTS, object & BLOCK_HEADER & BLOCK_BODY_WITH_RECEIPTS & PRE_CONFIRMED_BLOCK_HEADER>>

Block with transaction receipts

Implementation of

ProviderInterface.getBlockWithReceipts


getBlockStateUpdate()

Call Signature

getBlockStateUpdate(): Promise<{ block_hash: string; new_root: string; old_root: string; state_diff: { storage_diffs: object[]; deprecated_declared_classes: string[]; declared_classes: object[]; deployed_contracts: object[]; replaced_classes: object[]; nonces: object[]; migrated_compiled_classes?: object[]; }; }>

Defined in: src/provider/rpc.ts:321

Gets the state changes in a specific block (result of executing the requested block) Alternative method name for getStateUpdate with specific overloads

Returns

Promise<{ block_hash: string; new_root: string; old_root: string; state_diff: { storage_diffs: object[]; deprecated_declared_classes: string[]; declared_classes: object[]; deployed_contracts: object[]; replaced_classes: object[]; nonces: object[]; migrated_compiled_classes?: object[]; }; }>

StateUpdateResponse

Implementation of

ProviderInterface.getBlockStateUpdate

Call Signature

getBlockStateUpdate(blockIdentifier): Promise<{ block_hash: never; state_diff: { storage_diffs: object[]; deprecated_declared_classes: string[]; declared_classes: object[]; deployed_contracts: object[]; replaced_classes: object[]; nonces: object[]; migrated_compiled_classes?: object[]; }; old_root?: string; }>

Defined in: src/provider/rpc.ts:322

Gets the state changes in a specific block (result of executing the requested block) Alternative method name for getStateUpdate with specific overloads

Parameters
blockIdentifier

"pre_confirmed"

Returns

Promise<{ block_hash: never; state_diff: { storage_diffs: object[]; deprecated_declared_classes: string[]; declared_classes: object[]; deployed_contracts: object[]; replaced_classes: object[]; nonces: object[]; migrated_compiled_classes?: object[]; }; old_root?: string; }>

StateUpdateResponse

Implementation of

ProviderInterface.getBlockStateUpdate

Call Signature

getBlockStateUpdate(blockIdentifier): Promise<{ block_hash: string; new_root: string; old_root: string; state_diff: { storage_diffs: object[]; deprecated_declared_classes: string[]; declared_classes: object[]; deployed_contracts: object[]; replaced_classes: object[]; nonces: object[]; migrated_compiled_classes?: object[]; }; }>

Defined in: src/provider/rpc.ts:325

Gets the state changes in a specific block (result of executing the requested block) Alternative method name for getStateUpdate with specific overloads

Parameters
blockIdentifier

"latest"

Returns

Promise<{ block_hash: string; new_root: string; old_root: string; state_diff: { storage_diffs: object[]; deprecated_declared_classes: string[]; declared_classes: object[]; deployed_contracts: object[]; replaced_classes: object[]; nonces: object[]; migrated_compiled_classes?: object[]; }; }>

StateUpdateResponse

Implementation of

ProviderInterface.getBlockStateUpdate

Call Signature

getBlockStateUpdate(blockIdentifier?, contractAddresses?): Promise<StateUpdateResponse>

Defined in: src/provider/rpc.ts:326

Gets the state changes in a specific block (result of executing the requested block) Alternative method name for getStateUpdate with specific overloads

Parameters
blockIdentifier?

BlockIdentifier

contractAddresses?

BigNumberish[]

Returns

Promise<StateUpdateResponse>

StateUpdateResponse

Implementation of

ProviderInterface.getBlockStateUpdate


getBlockTransactionsTraces()

getBlockTransactionsTraces(blockIdentifier?, options?): Promise<BlockTransactionsTraces | BlockTransactionsTracesWithInitialReads>

Defined in: src/provider/rpc.ts:337

Get transaction traces for all transactions in a block

Parameters

blockIdentifier?

BlockIdentifier

block identifier

options?

(optional) additional request options

  • returnInitialReads - include initial storage reads in the trace response (RPC 0.10.1+)
returnInitialReads?

boolean

Returns

Promise<BlockTransactionsTraces | BlockTransactionsTracesWithInitialReads>

Array of transaction traces

Implementation of

ProviderInterface.getBlockTransactionsTraces


getBlockTransactionCount()

getBlockTransactionCount(blockIdentifier?): Promise<number>

Defined in: src/provider/rpc.ts:347

Get the number of transactions in a block

Parameters

blockIdentifier?

BlockIdentifier

block identifier

Returns

Promise<number>

Transaction count

Implementation of

ProviderInterface.getBlockTransactionCount


getTransaction()

getTransaction(txHash, options?): Promise<INVOKE_TXN_V0 & object | INVOKE_TXN_V1 & object | INVOKE_TXN_V3 & object | object & FUNCTION_CALL & object | DECLARE_TXN_V0 & object | DECLARE_TXN_V1 & object | DECLARE_TXN_V2 & object | DECLARE_TXN_V3 & object | DEPLOY_TXN & object | DEPLOY_ACCOUNT_TXN_V1 & object | DEPLOY_ACCOUNT_TXN_V3 & object>

Defined in: src/provider/rpc.ts:351

Gets the transaction information from a tx id.

Parameters

txHash

BigNumberish

options?

(optional) additional request options

  • includeProofFacts - include proof facts in the transaction response (RPC 0.10.1+)
includeProofFacts?

boolean

Returns

Promise<INVOKE_TXN_V0 & object | INVOKE_TXN_V1 & object | INVOKE_TXN_V3 & object | object & FUNCTION_CALL & object | DECLARE_TXN_V0 & object | DECLARE_TXN_V1 & object | DECLARE_TXN_V2 & object | DECLARE_TXN_V3 & object | DEPLOY_TXN & object | DEPLOY_ACCOUNT_TXN_V1 & object | DEPLOY_ACCOUNT_TXN_V3 & object>

the transaction object { transaction_id, status, transaction, block_number?, block_number?, transaction_index?, transaction_failure_reason? }

Implementation of

ProviderInterface.getTransaction


getTransactionByHash()

getTransactionByHash(txHash, options?): Promise<INVOKE_TXN_V0 & object | INVOKE_TXN_V1 & object | INVOKE_TXN_V3 & object | object & FUNCTION_CALL & object | DECLARE_TXN_V0 & object | DECLARE_TXN_V1 & object | DECLARE_TXN_V2 & object | DECLARE_TXN_V3 & object | DEPLOY_TXN & object | DEPLOY_ACCOUNT_TXN_V1 & object | DEPLOY_ACCOUNT_TXN_V3 & object>

Defined in: src/provider/rpc.ts:355

Gets the transaction information from a tx hash (alias for getTransaction)

Parameters

txHash

BigNumberish

transaction hash

options?

(optional) additional request options

  • includeProofFacts - include proof facts in the transaction response (RPC 0.10.1+)
includeProofFacts?

boolean

Returns

Promise<INVOKE_TXN_V0 & object | INVOKE_TXN_V1 & object | INVOKE_TXN_V3 & object | object & FUNCTION_CALL & object | DECLARE_TXN_V0 & object | DECLARE_TXN_V1 & object | DECLARE_TXN_V2 & object | DECLARE_TXN_V3 & object | DEPLOY_TXN & object | DEPLOY_ACCOUNT_TXN_V1 & object | DEPLOY_ACCOUNT_TXN_V3 & object>

Transaction information

Implementation of

ProviderInterface.getTransactionByHash


getTransactionByBlockIdAndIndex()

getTransactionByBlockIdAndIndex(blockIdentifier, index, options?): Promise<INVOKE_TXN_V0 & object | INVOKE_TXN_V1 & object | INVOKE_TXN_V3 & object | object & FUNCTION_CALL & object | DECLARE_TXN_V0 & object | DECLARE_TXN_V1 & object | DECLARE_TXN_V2 & object | DECLARE_TXN_V3 & object | DEPLOY_TXN & object | DEPLOY_ACCOUNT_TXN_V1 & object | DEPLOY_ACCOUNT_TXN_V3 & object>

Defined in: src/provider/rpc.ts:365

Gets transaction by block identifier and index

Parameters

blockIdentifier

BlockIdentifier

block identifier

index

number

transaction index in the block

options?

(optional) additional request options

  • includeProofFacts - include proof facts in the transaction response (RPC 0.10.1+)
includeProofFacts?

boolean

Returns

Promise<INVOKE_TXN_V0 & object | INVOKE_TXN_V1 & object | INVOKE_TXN_V3 & object | object & FUNCTION_CALL & object | DECLARE_TXN_V0 & object | DECLARE_TXN_V1 & object | DECLARE_TXN_V2 & object | DECLARE_TXN_V3 & object | DEPLOY_TXN & object | DEPLOY_ACCOUNT_TXN_V1 & object | DEPLOY_ACCOUNT_TXN_V3 & object>

Transaction information

Implementation of

ProviderInterface.getTransactionByBlockIdAndIndex


getTransactionReceipt()

getTransactionReceipt(txHash): Promise<GetTransactionReceiptResponse>

Defined in: src/provider/rpc.ts:376

Gets the transaction receipt from a tx hash.

Parameters

txHash

BigNumberish

Returns

Promise<GetTransactionReceiptResponse>

the transaction receipt object

Implementation of

ProviderInterface.getTransactionReceipt


getTransactionTrace()

Call Signature

getTransactionTrace<V>(txHash): Promise<V extends SupportedRpcVersion0_10 ? TRANSACTION_TRACE : TRANSACTION_TRACE>

Defined in: src/provider/rpc.ts:383

Gets the transaction trace

Type Parameters
V

V extends "0.9.0" | "0.10.0" | "0.10.2" | "0.10.3" = "0.9.0" | "0.10.0" | "0.10.2" | "0.10.3"

Parameters
txHash

BigNumberish

transaction hash

Returns

Promise<V extends SupportedRpcVersion0_10 ? TRANSACTION_TRACE : TRANSACTION_TRACE>

Transaction trace

Implementation of

ProviderInterface.getTransactionTrace

Call Signature

getTransactionTrace(txHash): Promise<TRANSACTION_TRACE | TRANSACTION_TRACE>

Defined in: src/provider/rpc.ts:388

Parameters
txHash

BigNumberish

Returns

Promise<TRANSACTION_TRACE | TRANSACTION_TRACE>

Implementation of

ProviderInterface.getTransactionTrace


getTransactionStatus()

getTransactionStatus(transactionHash): Promise<TXN_STATUS_RESULT>

Defined in: src/provider/rpc.ts:397

Get the status of a transaction

Parameters

transactionHash

BigNumberish

transaction hash

Returns

Promise<TXN_STATUS_RESULT>

Transaction status

Implementation of

ProviderInterface.getTransactionStatus


getSimulateTransaction()

getSimulateTransaction(invocations, options?): Promise<SimulateTransactionOverheadResponse>

Defined in: src/provider/rpc.ts:401

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

Parameters

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
  • (optional) returnInitialReads - include initial storage reads in the trace response (RPC 0.10.1+)

Returns

Promise<SimulateTransactionOverheadResponse>

an array of transaction trace and estimated fee

Implementation of

ProviderInterface.getSimulateTransaction


waitForTransaction()

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

Defined in: src/provider/rpc.ts:411

Wait for the transaction to be accepted

Parameters

txHash

BigNumberish

transaction hash

options?

waitForTransactionOptions

waitForTransactionOptions

  • (optional) retryInterval: number | undefined;
  • (optional) successStates: TransactionStatus[] | undefined;

Returns

Promise<GetTransactionReceiptResponse>

GetTransactionReceiptResponse

Implementation of

ProviderInterface.waitForTransaction


getStorageAt()

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

Defined in: src/provider/rpc.ts:423

Get the value of the storage (contract's variable) at the given address and key

Parameters

contractAddress

BigNumberish

key

BigNumberish

from getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)

blockIdentifier?

BlockIdentifier

block identifier

responseFlags?

"INCLUDE_LAST_UPDATE_BLOCK"[]

Returns

Promise<STORAGE_RESULT>

the value of the storage variable

Implementation of

ProviderInterface.getStorageAt


getClassHashAt()

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

Defined in: src/provider/rpc.ts:438

Returns the contract class hash in the given block for the contract deployed at the given address

Parameters

contractAddress

BigNumberish

contract address

blockIdentifier?

BlockIdentifier

block identifier

Returns

Promise<string>

Class hash

Implementation of

ProviderInterface.getClassHashAt


getClassByHash()

getClassByHash(classHash): Promise<LegacyContractClass | Omit<CompiledSierra, "sierra_program_debug_info">>

Defined in: src/provider/rpc.ts:442

Returns the contract class deployed under the given class hash.

Parameters

classHash

BigNumberish

class hash

Returns

Promise<LegacyContractClass | Omit<CompiledSierra, "sierra_program_debug_info">>

Contract class of compiled contract

Implementation of

ProviderInterface.getClassByHash


getClass()

getClass(classHash, blockIdentifier?): Promise<LegacyContractClass | Omit<CompiledSierra, "sierra_program_debug_info">>

Defined in: src/provider/rpc.ts:446

Get contract class by hash with optional block identifier

Parameters

classHash

BigNumberish

class hash

blockIdentifier?

BlockIdentifier

block identifier

Returns

Promise<LegacyContractClass | Omit<CompiledSierra, "sierra_program_debug_info">>

Contract class

Implementation of

ProviderInterface.getClass


getClassAt()

getClassAt(contractAddress, blockIdentifier?): Promise<LegacyContractClass | Omit<CompiledSierra, "sierra_program_debug_info">>

Defined in: src/provider/rpc.ts:452

Gets the contract class of the deployed contract.

Parameters

contractAddress

BigNumberish

contract address

blockIdentifier?

BlockIdentifier

block identifier

Returns

Promise<LegacyContractClass | Omit<CompiledSierra, "sierra_program_debug_info">>

Contract class of compiled contract

Implementation of

ProviderInterface.getClassAt


getContractVersion()

Call Signature

getContractVersion(contractAddress, classHash?, options?): Promise<ContractVersion>

Defined in: src/provider/rpc.ts:458

Gets the contract version from the provided address

Parameters
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

Call Signature

getContractVersion(contractAddress, classHash, options?): Promise<ContractVersion>

Defined in: src/provider/rpc.ts:463

Gets the contract version from the provided address

Parameters
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


getInvokeEstimateFee()

getInvokeEstimateFee(invocation, details, blockIdentifier?, skipValidate?): Promise<EstimateFeeResponseOverhead>

Defined in: src/provider/rpc.ts:496

Estimates the fee for a given INVOKE transaction

Parameters

invocation

Invocation

the invocation object containing:

  • contractAddress - the address of the contract
  • entrypoint - (optional) the entrypoint of the contract
  • calldata - (optional, defaults to []) the calldata
  • signature - (optional, defaults to []) the signature
details

InvocationsDetailsWithNonce

optional details containing:

  • nonce - optional nonce
  • version - optional version
blockIdentifier?

BlockIdentifier

(optional) block identifier

skipValidate?

boolean

(optional) skip cairo validate method

Returns

Promise<EstimateFeeResponseOverhead>

the estimated fee

Deprecated

Consider using getEstimateFeeBulk for multiple transactions

Example

const feeEstimate = await provider.getInvokeEstimateFee(invocation, details);
// Equivalent to:
const [feeEstimate] = await provider.getEstimateFeeBulk([{ type: ETransactionType.INVOKE, ...invocation, ...details }], options);

Alias

getEstimateFeeBulk - This method is an alias that calls getEstimateFeeBulk with a single transaction

Implementation of

ProviderInterface.getInvokeEstimateFee


getDeclareEstimateFee()

getDeclareEstimateFee(invocation, details, blockIdentifier?, skipValidate?): Promise<EstimateFeeResponseOverhead>

Defined in: src/provider/rpc.ts:510

Estimates the fee for a given DECLARE transaction

Parameters

invocation

DeclareContractTransaction

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<EstimateFeeResponseOverhead>

the estimated fee

Deprecated

Consider using getEstimateFeeBulk for multiple transactions

Example

const feeEstimate = await provider.getDeclareEstimateFee(transaction, details);
// Equivalent to:
const [feeEstimate] = await provider.getEstimateFeeBulk([{ type: ETransactionType.DECLARE, ...transaction, ...details }], options);

Alias

getEstimateFeeBulk - This method is an alias that calls getEstimateFeeBulk with a single transaction

Implementation of

ProviderInterface.getDeclareEstimateFee


getDeployAccountEstimateFee()

getDeployAccountEstimateFee(invocation, details, blockIdentifier?, skipValidate?): Promise<EstimateFeeResponseOverhead>

Defined in: src/provider/rpc.ts:524

Estimates the fee for a given DEPLOY_ACCOUNT transaction

Parameters

invocation

DeployAccountContractTransaction

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<EstimateFeeResponseOverhead>

the estimated fee

Deprecated

Consider using getEstimateFeeBulk for multiple transactions

Example

const feeEstimate = await provider.getDeployAccountEstimateFee(transaction, details);
// Equivalent to:
const [feeEstimate] = await provider.getEstimateFeeBulk([{ type: ETransactionType.DEPLOY_ACCOUNT, ...transaction, ...details }], options);

Alias

getEstimateFeeBulk - This method is an alias that calls getEstimateFeeBulk with a single transaction

Implementation of

ProviderInterface.getDeployAccountEstimateFee


getEstimateFeeBulk()

getEstimateFeeBulk(invocations, options?): Promise<EstimateFeeResponseBulkOverhead>

Defined in: src/provider/rpc.ts:538

Estimates the fee for a list of INVOKE transaction

Parameters

invocations

AccountInvocations

AccountInvocations - Complete invocations array with account details

options?

getEstimateFeeBulkOptions

getEstimateFeeBulkOptions

  • (optional) blockIdentifier - BlockIdentifier

Returns

Promise<EstimateFeeResponseBulkOverhead>

the estimated fee

Implementation of

ProviderInterface.getEstimateFeeBulk


invokeFunction()

invokeFunction(functionInvocation, details): Promise<{ transaction_hash: string; }>

Defined in: src/provider/rpc.ts:547

Invokes a function on starknet

Parameters

functionInvocation

Invocation

details

InvocationsDetailsWithNonce

optional details containing:

  • nonce - optional nonce
  • version - optional version
  • maxFee - optional maxFee

Returns

Promise<{ transaction_hash: string; }>

response from addTransaction

Implementation of

ProviderInterface.invokeFunction


invokeSignedTx()

invokeSignedTx(transaction): Promise<{ transaction_hash: string; }>

Defined in: src/provider/rpc.ts:579

Submit a pre-signed INVOKE_TXN_V3 transaction to the network.

Broadcasts a transaction previously built and signed by Account.getSignedTransaction(). Fees are already included in the signed transaction and will not be re-estimated.

Parameters

transaction

INVOKE_TXN_V3

A fully signed RPC.INVOKE_TXN_V3 object, as returned by Account.getSignedTransaction()

Returns

Promise<{ transaction_hash: string; }>

The transaction hash if waitMode is disabled (default), or the transaction receipt if waitMode is enabled.

Remarks

  • The transaction must be signed before calling this method ; use Account.getSignedTransaction() to produce it.
  • Resubmitting the same signed transaction (same nonce) will be rejected by the network.
  • If waitMode is enabled on the provider, this method waits for the transaction to be included in a block before returning.

Example

const signedTx = await account.getSignedTransaction([
{ contractAddress: erc20Address, entrypoint: 'transfer', calldata: [recipient, amount, 0] }
]);
// inspect or store signedTx, then submit when ready:
const { transaction_hash } = await provider.invokeSignedTx(signedTx);
await provider.waitForTransaction(transaction_hash);

declareContract()

declareContract(transaction, details): Promise<{ class_hash: string; transaction_hash: string; }>

Defined in: src/provider/rpc.ts:583

Declares a given compiled contract (json) to starknet

Parameters

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<{ class_hash: string; transaction_hash: string; }>

a confirmation of sending a transaction on the starknet contract

Implementation of

ProviderInterface.declareContract


deployAccountContract()

deployAccountContract(transaction, details): Promise<{ contract_address: string; transaction_hash: string; }>

Defined in: src/provider/rpc.ts:590

Deploys a given compiled Account contract (json) to starknet

Parameters

transaction

DeployAccountContractTransaction

details

InvocationsDetailsWithNonce

Returns

Promise<{ contract_address: string; transaction_hash: string; }>

a confirmation of sending a transaction on the starknet contract

Implementation of

ProviderInterface.deployAccountContract


callContract()

callContract(call, blockIdentifier?): Promise<string[]>

Defined in: src/provider/rpc.ts:597

Calls a function on the Starknet contract.

Parameters

call

Call

transaction to be called

blockIdentifier?

BlockIdentifier

block identifier

Returns

Promise<string[]>

the result of the function on the smart contract.

Implementation of

ProviderInterface.callContract


estimateMessageFee()

Call Signature

estimateMessageFee<V>(message, blockIdentifier?): Promise<V extends SupportedRpcVersion0_10 ? FEE_ESTIMATE : MESSAGE_FEE_ESTIMATE>

Defined in: src/provider/rpc.ts:601

Estimate the fee for a message from L1

Type Parameters
V

V extends "0.9.0" | "0.10.0" | "0.10.2" | "0.10.3" = "0.9.0" | "0.10.0" | "0.10.2" | "0.10.3"

Parameters
message

MSG_FROM_L1

L1 message

blockIdentifier?

BlockIdentifier

block identifier

Returns

Promise<V extends SupportedRpcVersion0_10 ? FEE_ESTIMATE : MESSAGE_FEE_ESTIMATE>

Fee estimate

Implementation of

ProviderInterface.estimateMessageFee

Call Signature

estimateMessageFee(message, blockIdentifier?): Promise<MESSAGE_FEE_ESTIMATE | FEE_ESTIMATE>

Defined in: src/provider/rpc.ts:607

Parameters
message

MSG_FROM_L1

blockIdentifier?

BlockIdentifier

Returns

Promise<MESSAGE_FEE_ESTIMATE | FEE_ESTIMATE>

Implementation of

ProviderInterface.estimateMessageFee


getSyncingStats()

getSyncingStats(): Promise<Syncing>

Defined in: src/provider/rpc.ts:618

Get node synchronization status

Returns

Promise<Syncing>

Sync status or false if not syncing

Implementation of

ProviderInterface.getSyncingStats


getEvents()

Call Signature

getEvents<V>(eventFilter): Promise<V extends SupportedRpcVersion0_10 ? EVENTS_CHUNK : EVENTS_CHUNK>

Defined in: src/provider/rpc.ts:622

Get events matching the given filter

Type Parameters
V

V extends "0.9.0" | "0.10.0" | "0.10.2" | "0.10.3" = "0.9.0" | "0.10.0" | "0.10.2" | "0.10.3"

Parameters
eventFilter

V extends SupportedRpcVersion0_10 ? EventFilter : EventFilter

event filter

Returns

Promise<V extends SupportedRpcVersion0_10 ? EVENTS_CHUNK : EVENTS_CHUNK>

Events and pagination info

Implementation of

ProviderInterface.getEvents

Call Signature

getEvents(eventFilter): Promise<EVENTS_CHUNK | EVENTS_CHUNK>

Defined in: src/provider/rpc.ts:625

Parameters
eventFilter

EventFilter | EventFilter

Returns

Promise<EVENTS_CHUNK | EVENTS_CHUNK>

Implementation of

ProviderInterface.getEvents


verifyMessageInStarknet()

verifyMessageInStarknet(message, signature, accountAddress, signatureVerificationFunctionName?, signatureVerificationResponse?): Promise<boolean>

Defined in: src/provider/rpc.ts:640

Verify in Starknet a signature of a TypedData object or of a given hash.

Parameters

message

TypedData | BigNumberish

TypedData object to be verified, or message hash to be verified.

signature

Signature

signature of the message.

accountAddress

BigNumberish

address of the account that has signed the message.

signatureVerificationFunctionName?

string

if account contract with non standard account verification function name.

signatureVerificationResponse?

if account contract with non standard response of verification function.

okResponse

string[]

nokResponse

string[]

error

string[]

Returns

Promise<boolean>

const myTypedMessage: TypedMessage = .... ;
const messageHash = typedData.getMessageHash(myTypedMessage,accountAddress);
const sign: WeierstrassSignatureType = ec.starkCurve.sign(messageHash, privateKey);
const accountAddress = "0x43b7240d227aa2fb8434350b3321c40ac1b88c7067982549e7609870621b535";
const result1 = await myRpcProvider.verifyMessageInStarknet(myTypedMessage, sign, accountAddress);
const result2 = await myRpcProvider.verifyMessageInStarknet(messageHash, sign, accountAddress);
// result1 = result2 = true

Implementation of

ProviderInterface.verifyMessageInStarknet


isClassDeclared()

isClassDeclared(contractClassIdentifier, blockIdentifier?): Promise<boolean>

Defined in: src/provider/rpc.ts:657

Test if class is already declared

Parameters

contractClassIdentifier

ContractClassIdentifier

contract class identifier

blockIdentifier?

BlockIdentifier

block identifier

Returns

Promise<boolean>

true if class is declared

Implementation of

ProviderInterface.isClassDeclared


prepareInvocations()

prepareInvocations(invocations): Promise<Invocations>

Defined in: src/provider/rpc.ts:685

Build bulk invocations with auto-detect declared class

Parameters

invocations

Invocations

array of invocations

Returns

Promise<Invocations>

Prepared invocations

Implementation of

ProviderInterface.prepareInvocations


getL1MessagesStatus()

Call Signature

getL1MessagesStatus<V>(transactionHash): Promise<V extends SupportedRpcVersion0_10 ? L1L2MessagesStatus : L1L2MessagesStatus>

Defined in: src/provider/rpc.ts:706

Get L1 messages status for a transaction

Type Parameters
V

V extends "0.9.0" | "0.10.0" | "0.10.2" | "0.10.3" = "0.9.0" | "0.10.0" | "0.10.2" | "0.10.3"

Parameters
transactionHash

BigNumberish

L1 transaction hash

Returns

Promise<V extends SupportedRpcVersion0_10 ? L1L2MessagesStatus : L1L2MessagesStatus>

L1 message status

Implementation of

ProviderInterface.getL1MessagesStatus

Call Signature

getL1MessagesStatus(transactionHash): Promise<L1L2MessagesStatus | L1L2MessagesStatus>

Defined in: src/provider/rpc.ts:713

Parameters
transactionHash

BigNumberish

Returns

Promise<L1L2MessagesStatus | L1L2MessagesStatus>

Implementation of

ProviderInterface.getL1MessagesStatus


getStorageProof()

getStorageProof(classHashes, contractAddresses, contractsStorageKeys, blockIdentifier?): Promise<StorageProof>

Defined in: src/provider/rpc.ts:722

Get Merkle paths in state tries

Parameters

classHashes

BigNumberish[]

class hashes

contractAddresses

BigNumberish[]

contract addresses

contractsStorageKeys

CONTRACT_STORAGE_KEYS[]

storage keys

blockIdentifier?

BlockIdentifier

block identifier

Returns

Promise<StorageProof>

Storage proof

Implementation of

ProviderInterface.getStorageProof


getCompiledCasm()

getCompiledCasm(classHash): Promise<CASM_COMPILED_CONTRACT_CLASS>

Defined in: src/provider/rpc.ts:736

Get compiled CASM contract class

Parameters

classHash

BigNumberish

class hash

Returns

Promise<CASM_COMPILED_CONTRACT_CLASS>

Compiled CASM contract class

Implementation of

ProviderInterface.getCompiledCasm


getEstimateTip()

getEstimateTip(blockIdentifier?, options?): Promise<TipEstimate>

Defined in: src/provider/rpc.ts:740

Get transaction tip estimation based on network analysis

Parameters

blockIdentifier?

BlockIdentifier

block identifier to analyze from

options?

TipAnalysisOptions = {}

tip analysis options

Returns

Promise<TipEstimate>

Tip estimation with statistics

Example

const tipEstimate = await provider.getEstimateTip('latest', {
maxBlocks: 10,
minTxsNecessary: 5
});
console.log('Recommended tip:', tipEstimate.recommendedTip);

Implementation of

ProviderInterface.getEstimateTip


getStarkName()

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

Defined in: src/plugins/starknet-id/index.ts:26

Parameters

address

BigNumberish

StarknetIdContract?

string

Returns

Promise<string>

Inherited from

StarknetIdProviderMethods.getStarkName


getAddressFromStarkName()

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

Defined in: src/plugins/starknet-id/index.ts:27

Parameters

name

string

StarknetIdContract?

string

Returns

Promise<string>

Inherited from

StarknetIdProviderMethods.getAddressFromStarkName


getStarkProfile()

getStarkProfile(address, StarknetIdContract?, StarknetIdIdentityContract?, StarknetIdVerifierContract?, StarknetIdPfpContract?, StarknetIdPopContract?, StarknetIdMulticallContract?): Promise<StarkProfile>

Defined in: src/plugins/starknet-id/index.ts:28

Parameters

address

BigNumberish

StarknetIdContract?

string

StarknetIdIdentityContract?

string

StarknetIdVerifierContract?

string

StarknetIdPfpContract?

string

StarknetIdPopContract?

string

StarknetIdMulticallContract?

string

Returns

Promise<StarkProfile>

Inherited from

StarknetIdProviderMethods.getStarkProfile


getBrotherName()

getBrotherName(address, BrotherIdContract?): Promise<string>

Defined in: src/plugins/brother-id/index.ts:47

Parameters

address

BigNumberish

BrotherIdContract?

string

Returns

Promise<string>

Inherited from

BrotherIdProviderMethods.getBrotherName


getAddressFromBrotherName()

getAddressFromBrotherName(name, BrotherIdContract?): Promise<string>

Defined in: src/plugins/brother-id/index.ts:48

Parameters

name

string

BrotherIdContract?

string

Returns

Promise<string>

Inherited from

BrotherIdProviderMethods.getAddressFromBrotherName


getBrotherProfile()

getBrotherProfile(address, BrotherIdContract?): Promise<BrotherProfile>

Defined in: src/plugins/brother-id/index.ts:49

Parameters

address

BigNumberish

BrotherIdContract?

string

Returns

Promise<BrotherProfile>

Inherited from

BrotherIdProviderMethods.getBrotherProfile