Skip to main content
Version: 11.x

Abstract Class: ProviderInterface

Defined in: src/provider/interface.ts:46

Constructors​

Constructor​

new ProviderInterface(): ProviderInterface

Returns​

ProviderInterface

Properties​

channel​

abstract channel: RpcChannel | RpcChannel | RpcChannel | RpcChannel

Defined in: src/provider/interface.ts:47


responseParser​

abstract responseParser: RPCResponseParser

Defined in: src/provider/interface.ts:53

Methods​

getChainId()​

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

Defined in: src/provider/interface.ts:60

Gets the Starknet chain Id

Returns​

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

the chain Id


callContract()​

abstract callContract(call, blockIdentifier?): Promise<CallContractResponse>

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

Calls a function on the Starknet contract.

Parameters​

call​

Call

transaction to be called

blockIdentifier?​

BlockIdentifier

block identifier

Returns​

Promise<CallContractResponse>

the result of the function on the smart contract.


getBlock()​

Call Signature​

abstract getBlock(): 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/interface.ts:118

Gets the header and the transaction hashes of a block (RPC starknet_getBlockWithTxHashes).

The response contains the block metadata (hash, number, parent hash, timestamp, status, gas prices, sequencer address, ...) plus a transactions array holding only the hashes of the transactions included in the block — not their content. To get the full transactions use getBlockWithTxs, and for their receipts use getBlockWithReceipts.

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 header together with the list of its transaction hashes

Example​
const block = await provider.getBlock('latest');
// {
// status: 'ACCEPTED_ON_L2',
// block_hash: '0x3a1b...',
// block_number: 123456,
// parent_hash: '0x28f5...',
// timestamp: 1700000000,
// sequencer_address: '0x1176a1...',
// transactions: ['0x1d2c...', '0x5e8f...'], // transaction hashes only
// ...
// }

// By block number or hash:
await provider.getBlock(123456);
await provider.getBlock('0x3a1b...');

// Block still being built (fields differ from a closed block):
const pending = await provider.getBlock('pre_confirmed');

Call Signature​

abstract 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/interface.ts:119

Gets the header and the transaction hashes of a block (RPC starknet_getBlockWithTxHashes).

The response contains the block metadata (hash, number, parent hash, timestamp, status, gas prices, sequencer address, ...) plus a transactions array holding only the hashes of the transactions included in the block — not their content. To get the full transactions use getBlockWithTxs, and for their receipts use getBlockWithReceipts.

Parameters​
blockIdentifier​

"pre_confirmed"

which block to fetch. Accepts:

  • a block number: number or decimal string (e.g. 123456)
  • a block hash: hex string or bigint (e.g. '0x3a1b...')
  • a block tag string:
    • 'latest' — the most recent block already accepted on L2
    • 'pre_confirmed' — the block currently being built, not yet closed (its fields differ: no block_hash/status, hence the dedicated PreConfirmedBlock return type)
  • null — resolved as the 'latest' tag

When omitted, the provider's default block identifier is used ('latest').

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 header together with the list of its transaction hashes

Example​
const block = await provider.getBlock('latest');
// {
// status: 'ACCEPTED_ON_L2',
// block_hash: '0x3a1b...',
// block_number: 123456,
// parent_hash: '0x28f5...',
// timestamp: 1700000000,
// sequencer_address: '0x1176a1...',
// transactions: ['0x1d2c...', '0x5e8f...'], // transaction hashes only
// ...
// }

// By block number or hash:
await provider.getBlock(123456);
await provider.getBlock('0x3a1b...');

// Block still being built (fields differ from a closed block):
const pending = await provider.getBlock('pre_confirmed');

Call Signature​

abstract 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/interface.ts:120

Gets the header and the transaction hashes of a block (RPC starknet_getBlockWithTxHashes).

The response contains the block metadata (hash, number, parent hash, timestamp, status, gas prices, sequencer address, ...) plus a transactions array holding only the hashes of the transactions included in the block — not their content. To get the full transactions use getBlockWithTxs, and for their receipts use getBlockWithReceipts.

Parameters​
blockIdentifier​

"latest"

which block to fetch. Accepts:

  • a block number: number or decimal string (e.g. 123456)
  • a block hash: hex string or bigint (e.g. '0x3a1b...')
  • a block tag string:
    • 'latest' — the most recent block already accepted on L2
    • 'pre_confirmed' — the block currently being built, not yet closed (its fields differ: no block_hash/status, hence the dedicated PreConfirmedBlock return type)
  • null — resolved as the 'latest' tag

When omitted, the provider's default block identifier is used ('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 header together with the list of its transaction hashes

Example​
const block = await provider.getBlock('latest');
// {
// status: 'ACCEPTED_ON_L2',
// block_hash: '0x3a1b...',
// block_number: 123456,
// parent_hash: '0x28f5...',
// timestamp: 1700000000,
// sequencer_address: '0x1176a1...',
// transactions: ['0x1d2c...', '0x5e8f...'], // transaction hashes only
// ...
// }

// By block number or hash:
await provider.getBlock(123456);
await provider.getBlock('0x3a1b...');

// Block still being built (fields differ from a closed block):
const pending = await provider.getBlock('pre_confirmed');

Call Signature​

abstract getBlock(blockIdentifier): Promise<GetBlockResponse>

Defined in: src/provider/interface.ts:121

Gets the header and the transaction hashes of a block (RPC starknet_getBlockWithTxHashes).

The response contains the block metadata (hash, number, parent hash, timestamp, status, gas prices, sequencer address, ...) plus a transactions array holding only the hashes of the transactions included in the block — not their content. To get the full transactions use getBlockWithTxs, and for their receipts use getBlockWithReceipts.

Parameters​
blockIdentifier​

BlockIdentifier

which block to fetch. Accepts:

  • a block number: number or decimal string (e.g. 123456)
  • a block hash: hex string or bigint (e.g. '0x3a1b...')
  • a block tag string:
    • 'latest' — the most recent block already accepted on L2
    • 'pre_confirmed' — the block currently being built, not yet closed (its fields differ: no block_hash/status, hence the dedicated PreConfirmedBlock return type)
  • null — resolved as the 'latest' tag

When omitted, the provider's default block identifier is used ('latest').

Returns​

Promise<GetBlockResponse>

the block header together with the list of its transaction hashes

Example​
const block = await provider.getBlock('latest');
// {
// status: 'ACCEPTED_ON_L2',
// block_hash: '0x3a1b...',
// block_number: 123456,
// parent_hash: '0x28f5...',
// timestamp: 1700000000,
// sequencer_address: '0x1176a1...',
// transactions: ['0x1d2c...', '0x5e8f...'], // transaction hashes only
// ...
// }

// By block number or hash:
await provider.getBlock(123456);
await provider.getBlock('0x3a1b...');

// Block still being built (fields differ from a closed block):
const pending = await provider.getBlock('pre_confirmed');

getClassAt()​

abstract getClassAt(contractAddress, blockIdentifier?): Promise<ContractClassResponse>

Defined in: src/provider/interface.ts:130

Gets the contract class of the deployed contract.

Parameters​

contractAddress​

BigNumberish

contract address

blockIdentifier?​

BlockIdentifier

block identifier

Returns​

Promise<ContractClassResponse>

Contract class of compiled contract


getL1GasPrice()​

abstract getL1GasPrice(blockIdentifier?): Promise<string>

Defined in: src/provider/interface.ts:141

Gets the price of l1 gas in the block

Parameters​

blockIdentifier?​

BlockIdentifier

block identifier

Returns​

Promise<string>

gas price of the block


getL1MessageHash()​

abstract getL1MessageHash(l2TxHash): Promise<string>

Defined in: src/provider/interface.ts:154

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'

getClassHashAt()​

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

Defined in: src/provider/interface.ts:163

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


getClassByHash()​

abstract getClassByHash(classHash): Promise<ContractClassResponse>

Defined in: src/provider/interface.ts:174

Returns the contract class deployed under the given class hash.

Parameters​

classHash​

BigNumberish

class hash

Returns​

Promise<ContractClassResponse>

Contract class of compiled contract


getNonceForAddress()​

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

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

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


getStorageAt()​

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

Defined in: src/provider/interface.ts:195

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


getTransaction()​

abstract getTransaction(transactionHash, options?): Promise<TransactionWithHash>

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

Gets the transaction information from a tx id.

Parameters​

transactionHash​

BigNumberish

options?​

(optional) additional request options

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

boolean

Returns​

Promise<TransactionWithHash>

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


getTransactionReceipt()​

abstract getTransactionReceipt(transactionHash): Promise<GetTransactionReceiptResponse>

Defined in: src/provider/interface.ts:221

Gets the transaction receipt from a tx hash.

Parameters​

transactionHash​

BigNumberish

Returns​

Promise<GetTransactionReceiptResponse>

the transaction receipt object


deployAccountContract()​

abstract deployAccountContract(payload, details): Promise<DeployContractResponse>

Defined in: src/provider/interface.ts:234

Deploys a given compiled Account contract (json) to starknet

Parameters​

payload​

DeployAccountContractPayload

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


invokeFunction()​

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

Defined in: src/provider/interface.ts:252

Invokes a function on starknet

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

Returns​

Promise<{ transaction_hash: string; }>

response from addTransaction


declareContract()​

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

Defined in: src/provider/interface.ts:268

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

Returns​

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

a confirmation of sending a transaction on the starknet contract


getInvokeEstimateFee()​

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

Defined in: src/provider/interface.ts:296

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);

Remarks​

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


getDeclareEstimateFee()​

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

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

Estimates the fee for a given DECLARE transaction

Parameters​

transaction​

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
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);

Remarks​

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


getDeployAccountEstimateFee()​

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

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

Estimates the fee for a given DEPLOY_ACCOUNT transaction

Parameters​

transaction​

DeployAccountContractTransaction

transaction payload to be deployed containing:

  • classHash
  • constructorCalldata
  • addressSalt
  • signature - (defaults to []) the signature
details​

InvocationsDetailsWithNonce

optional details containing:

  • 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.getDeployAccountEstimateFee(transaction, details);
// Equivalent to:
const [feeEstimate] = await provider.getEstimateFeeBulk([{ type: ETransactionType.DEPLOY_ACCOUNT, ...transaction, ...details }], options);

Remarks​

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


getEstimateFeeBulk()​

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

Defined in: src/provider/interface.ts:370

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


waitForTransaction()​

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

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

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


getSimulateTransaction()​

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

Defined in: src/provider/interface.ts:399

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


getStateUpdate()​

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

Defined in: src/provider/interface.ts:410

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

Parameters​

blockIdentifier?​

BlockIdentifier

block identifier

contractAddresses?​

BigNumberish[]

Returns​

Promise<StateUpdateResponse>

StateUpdateResponse


getBlockStateUpdate()​

Call Signature​

abstract 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/interface.ts:421

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​

abstract 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/interface.ts:422

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

Call Signature​

abstract 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/interface.ts:425

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

Call Signature​

abstract getBlockStateUpdate(blockIdentifier?): Promise<StateUpdateResponse>

Defined in: src/provider/interface.ts:426

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

Returns​

Promise<StateUpdateResponse>

StateUpdateResponse


getContractVersion()​

Call Signature​

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

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

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>

Call Signature​

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

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

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>


getBlockLatestAccepted()​

abstract getBlockLatestAccepted(): Promise<{ block_hash: string; block_number: number; }>

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

Get the most recent accepted block hash and number

Returns​

Promise<{ block_hash: string; block_number: number; }>

Object containing block hash and number


getBlockNumber()​

abstract getBlockNumber(): Promise<number>

Defined in: src/provider/interface.ts:469

Get the most recent accepted block number

Returns​

Promise<number>

Number of the latest block


getBlockWithTxHashes()​

abstract getBlockWithTxHashes(blockIdentifier?): Promise<any>

Defined in: src/provider/interface.ts:476

Get block information with transaction hashes

Parameters​

blockIdentifier?​

BlockIdentifier

block identifier

Returns​

Promise<any>

Block with transaction hashes


getBlockWithTxs()​

abstract getBlockWithTxs(blockIdentifier?, options?): Promise<any>

Defined in: src/provider/interface.ts:485

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

Block with full transactions


getBlockWithReceipts()​

abstract getBlockWithReceipts(blockIdentifier?, options?): Promise<any>

Defined in: src/provider/interface.ts:497

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

Block with transaction receipts


getBlockTransactionsTraces()​

abstract getBlockTransactionsTraces(blockIdentifier?, options?): Promise<any>

Defined in: src/provider/interface.ts:509

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

Array of transaction traces


getBlockTransactionCount()​

abstract getBlockTransactionCount(blockIdentifier?): Promise<number>

Defined in: src/provider/interface.ts:519

Get the number of transactions in a block

Parameters​

blockIdentifier?​

BlockIdentifier

block identifier

Returns​

Promise<number>

Transaction count


waitForBlock()​

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

Defined in: src/provider/interface.ts:531

Pause execution until a specified block is created

Parameters​

blockIdentifier?​

BlockIdentifier

block number or tag

retryInterval?​

number

milliseconds between requests (default: 5000)

Returns​

Promise<void>

Example​

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

getTransactionByHash()​

abstract getTransactionByHash(txHash, options?): Promise<TransactionWithHash>

Defined in: src/provider/interface.ts:544

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

Transaction information


getTransactionByBlockIdAndIndex()​

abstract getTransactionByBlockIdAndIndex(blockIdentifier, index, options?): Promise<TransactionWithHash>

Defined in: src/provider/interface.ts:557

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

Transaction information


getTransactionTrace()​

abstract getTransactionTrace(txHash): Promise<TRANSACTION_TRACE | TRANSACTION_TRACE>

Defined in: src/provider/interface.ts:568

Gets the transaction trace

Parameters​

txHash​

BigNumberish

transaction hash

Returns​

Promise<TRANSACTION_TRACE | TRANSACTION_TRACE>

Transaction trace


getTransactionStatus()​

abstract getTransactionStatus(transactionHash): Promise<any>

Defined in: src/provider/interface.ts:577

Get the status of a transaction

Parameters​

transactionHash​

BigNumberish

transaction hash

Returns​

Promise<any>

Transaction status


fetch()​

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

Defined in: src/provider/interface.ts:587

Direct RPC method call

Parameters​

method​

string

RPC method name

params?​

object

method parameters

id?​

string | number

request ID

Returns​

Promise<any>

RPC response


readSpecVersion()​

abstract readSpecVersion(): string | undefined

Defined in: src/provider/interface.ts:593

Read channel spec version

Returns​

string | undefined

Spec version string or undefined if not set


getSpecVersion()​

abstract getSpecVersion(): Promise<string>

Defined in: src/provider/interface.ts:599

Get channel spec version

Returns​

Promise<string>

Promise resolving to spec version


setUpSpecVersion()​

abstract setUpSpecVersion(): Promise<string>

Defined in: src/provider/interface.ts:605

Setup channel spec version and return it

Returns​

Promise<string>

Promise resolving to spec version


getClass()​

abstract getClass(classHash, blockIdentifier?): Promise<ContractClassResponse>

Defined in: src/provider/interface.ts:614

Get contract class by hash with optional block identifier

Parameters​

classHash​

BigNumberish

class hash

blockIdentifier?​

BlockIdentifier

block identifier

Returns​

Promise<ContractClassResponse>

Contract class


estimateMessageFee()​

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

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

Estimate the fee for a message from L1

Parameters​

message​

MSG_FROM_L1

L1 message

blockIdentifier?​

BlockIdentifier

block identifier

Returns​

Promise<MESSAGE_FEE_ESTIMATE | FEE_ESTIMATE>

Fee estimate


getSyncingStats()​

abstract getSyncingStats(): Promise<any>

Defined in: src/provider/interface.ts:634

Get node synchronization status

Returns​

Promise<any>

Sync status or false if not syncing


getEvents()​

abstract getEvents(eventFilter): Promise<EVENTS_CHUNK | EVENTS_CHUNK>

Defined in: src/provider/interface.ts:641

Get events matching the given filter

Parameters​

eventFilter​

EventFilter | EventFilter

event filter

Returns​

Promise<EVENTS_CHUNK | EVENTS_CHUNK>

Events and pagination info


verifyMessageInStarknet()​

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

Defined in: src/provider/interface.ts:663

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

isClassDeclared()​

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

Defined in: src/provider/interface.ts:681

Test if class is already declared

Parameters​

contractClassIdentifier​

ContractClassIdentifier

contract class identifier

blockIdentifier?​

BlockIdentifier

block identifier

Returns​

Promise<boolean>

true if class is declared


prepareInvocations()​

abstract prepareInvocations(invocations): Promise<Invocations>

Defined in: src/provider/interface.ts:691

Build bulk invocations with auto-detect declared class

Parameters​

invocations​

Invocations

array of invocations

Returns​

Promise<Invocations>

Prepared invocations


getL1MessagesStatus()​

abstract getL1MessagesStatus(transactionHash): Promise<L1L2MessagesStatus | L1L2MessagesStatus>

Defined in: src/provider/interface.ts:698

Get L1 messages status for a transaction

Parameters​

transactionHash​

BigNumberish

L1 transaction hash

Returns​

Promise<L1L2MessagesStatus | L1L2MessagesStatus>

L1 message status


getStorageProof()​

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

Defined in: src/provider/interface.ts:710

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


getCompiledCasm()​

abstract getCompiledCasm(classHash): Promise<CASM_COMPILED_CONTRACT_CLASS>

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

Get compiled CASM contract class

Parameters​

classHash​

BigNumberish

class hash

Returns​

Promise<CASM_COMPILED_CONTRACT_CLASS>

Compiled CASM contract class


getEstimateTip()​

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

Defined in: src/provider/interface.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);