Abstract Class: ProviderInterface
Defined in: src/provider/interface.ts:46
Constructors
Constructor
new ProviderInterface():
ProviderInterface
Returns
ProviderInterface
Properties
channel
abstractchannel:RpcChannel|RpcChannel|RpcChannel
Defined in: src/provider/interface.ts:47
responseParser
abstractresponseParser:RPCResponseParser
Defined in: src/provider/interface.ts:49
Methods
getChainId()
abstractgetChainId():Promise<"0x534e5f4d41494e"|"0x534e5f5345504f4c4941">
Defined in: src/provider/interface.ts:56
Gets the Starknet chain Id
Returns
Promise<"0x534e5f4d41494e" | "0x534e5f5345504f4c4941">
the chain Id
callContract()
abstractcallContract(call,blockIdentifier?):Promise<CallContractResponse>
Defined in: src/provider/interface.ts:65
Calls a function on the Starknet contract.
Parameters
call
transaction to be called
blockIdentifier?
block identifier
Returns
Promise<CallContractResponse>
the result of the function on the smart contract.
getBlock()
Call Signature
abstractgetBlock():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:75
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
Call Signature
abstractgetBlock(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:76
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
Call Signature
abstractgetBlock(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:77
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
Call Signature
abstractgetBlock(blockIdentifier):Promise<GetBlockResponse>
Defined in: src/provider/interface.ts:78
Gets the block information
Parameters
blockIdentifier
Returns
Promise<GetBlockResponse>
the block object
getClassAt()
abstractgetClassAt(contractAddress,blockIdentifier?):Promise<ContractClassResponse>
Defined in: src/provider/interface.ts:87
Gets the contract class of the deployed contract.
Parameters
contractAddress
contract address
blockIdentifier?
block identifier
Returns
Promise<ContractClassResponse>
Contract class of compiled contract
getL1GasPrice()
abstractgetL1GasPrice(blockIdentifier?):Promise<string>
Defined in: src/provider/interface.ts:98
Gets the price of l1 gas in the block
Parameters
blockIdentifier?
block identifier
Returns
Promise<string>
gas price of the block
getL1MessageHash()
abstractgetL1MessageHash(l2TxHash):Promise<string>
Defined in: src/provider/interface.ts:111
Get L1 message hash from L2 transaction hash
Parameters
l2TxHash
L2 transaction hash
Returns
Promise<string>
Hex string of L1 message hash
Example
In Sepolia Testnet :
const result = provider.getL1MessageHash('0x28dfc05eb4f261b37ddad451ff22f1d08d4e3c24dc646af0ec69fa20e096819');
// result = '0x55b3f8b6e607fffd9b4d843dfe8f9b5c05822cd94fcad8797deb01d77805532a'
getClassHashAt()
abstractgetClassHashAt(contractAddress,blockIdentifier?):Promise<string>
Defined in: src/provider/interface.ts:120
Returns the contract class hash in the given block for the contract deployed at the given address
Parameters
contractAddress
contract address
blockIdentifier?
block identifier
Returns
Promise<string>
Class hash
getClassByHash()
abstractgetClassByHash(classHash):Promise<ContractClassResponse>
Defined in: src/provider/interface.ts:131
Returns the contract class deployed under the given class hash.
Parameters
classHash
class hash
Returns
Promise<ContractClassResponse>
Contract class of compiled contract
getNonceForAddress()
abstractgetNonceForAddress(contractAddress,blockIdentifier?):Promise<string>
Defined in: src/provider/interface.ts:139
Returns the nonce associated with the given address in the given block
Parameters
contractAddress
contract address
blockIdentifier?
Returns
Promise<string>
the hex nonce
getStorageAt()
abstractgetStorageAt(contractAddress,key,blockIdentifier?,responseFlags?):Promise<STORAGE_RESULT>
Defined in: src/provider/interface.ts:152
Get the value of the storage (contract's variable) at the given address and key
Parameters
contractAddress
key
from getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)
blockIdentifier?
block identifier
responseFlags?
"INCLUDE_LAST_UPDATE_BLOCK"[]
Returns
Promise<STORAGE_RESULT>
the value of the storage variable
getTransaction()
abstractgetTransaction(transactionHash,options?):Promise<TransactionWithHash>
Defined in: src/provider/interface.ts:167
Gets the transaction information from a tx id.
Parameters
transactionHash
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()
abstractgetTransactionReceipt(transactionHash):Promise<GetTransactionReceiptResponse>
Defined in: src/provider/interface.ts:178
Gets the transaction receipt from a tx hash.
Parameters
transactionHash
Returns
Promise<GetTransactionReceiptResponse>
the transaction receipt object
deployAccountContract()
abstractdeployAccountContract(payload,details):Promise<DeployContractResponse>
Defined in: src/provider/interface.ts:191
Deploys a given compiled Account contract (json) to starknet
Parameters
payload
payload to be deployed containing:
- compiled contract code
- constructor calldata
- address salt
details
Returns
Promise<DeployContractResponse>
a confirmation of sending a transaction on the starknet contract
invokeFunction()
abstractinvokeFunction(invocation,details):Promise<{transaction_hash:string; }>
Defined in: src/provider/interface.ts:210
Invokes a function on starknet
Parameters
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
optional details containing:
- nonce - optional nonce
- version - optional version
- maxFee - optional maxFee
Returns
Promise<{ transaction_hash: string; }>
response from addTransaction
declareContract()
abstractdeclareContract(transaction,details):Promise<{class_hash:string;transaction_hash:string; }>
Defined in: src/provider/interface.ts:227
Declares a given compiled contract (json) to starknet
Parameters
transaction
transaction payload to be deployed containing:
- compiled contract code
- sender address
- signature
details
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
getInvokeEstimateFee()
abstractgetInvokeEstimateFee(invocation,details,blockIdentifier?,skipValidate?):Promise<EstimateFeeResponseOverhead>
Defined in: src/provider/interface.ts:255
Estimates the fee for a given INVOKE transaction
Parameters
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
optional details containing:
- nonce - optional nonce
- version - optional version
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
getDeclareEstimateFee()
abstractgetDeclareEstimateFee(transaction,details,blockIdentifier?,skipValidate?):Promise<EstimateFeeResponseOverhead>
Defined in: src/provider/interface.ts:285
Estimates the fee for a given DECLARE transaction
Parameters
transaction
transaction payload to be declared containing:
- compiled contract code
- sender address
- signature - (defaults to []) the signature
details
optional details containing:
- nonce
- version - optional version
- optional maxFee
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
getDeployAccountEstimateFee()
abstractgetDeployAccountEstimateFee(transaction,details,blockIdentifier?,skipValidate?):Promise<EstimateFeeResponseOverhead>
Defined in: src/provider/interface.ts:316
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
optional details containing:
- nonce
- version - optional version
- optional maxFee
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
getEstimateFeeBulk()
abstractgetEstimateFeeBulk(invocations,options?):Promise<EstimateFeeResponseBulkOverhead>
Defined in: src/provider/interface.ts:331
Estimates the fee for a list of INVOKE transaction
Parameters
invocations
AccountInvocations - Complete invocations array with account details
options?
getEstimateFeeBulkOptions
- (optional) blockIdentifier - BlockIdentifier
Returns
Promise<EstimateFeeResponseBulkOverhead>
the estimated fee
waitForTransaction()
abstractwaitForTransaction(txHash,options?):Promise<GetTransactionReceiptResponse>
Defined in: src/provider/interface.ts:344
Wait for the transaction to be accepted
Parameters
txHash
transaction hash
options?
waitForTransactionOptions
- (optional) retryInterval: number | undefined;
- (optional) successStates: TransactionStatus[] | undefined;
Returns
Promise<GetTransactionReceiptResponse>
GetTransactionReceiptResponse
getSimulateTransaction()
abstractgetSimulateTransaction(invocations,options?):Promise<SimulateTransactionOverheadResponse>
Defined in: src/provider/interface.ts:360
Simulates the transaction and returns the transaction trace and estimated fee.
Parameters
invocations
AccountInvocations - Complete invocations array with account details
options?
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()
abstractgetStateUpdate(blockIdentifier?,contractAddresses?):Promise<StateUpdateResponse>
Defined in: src/provider/interface.ts:371
Gets the state changes in a specific block (result of executing the requested block)
Parameters
blockIdentifier?
block identifier
contractAddresses?
Returns
Promise<StateUpdateResponse>
StateUpdateResponse
getBlockStateUpdate()
Call Signature
abstractgetBlockStateUpdate():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:382
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
abstractgetBlockStateUpdate(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:383
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
abstractgetBlockStateUpdate(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:386
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
abstractgetBlockStateUpdate(blockIdentifier?):Promise<StateUpdateResponse>
Defined in: src/provider/interface.ts:387
Gets the state changes in a specific block (result of executing the requested block) Alternative method name for getStateUpdate with specific overloads
Parameters
blockIdentifier?
Returns
Promise<StateUpdateResponse>
StateUpdateResponse
getContractVersion()
Call Signature
abstractgetContractVersion(contractAddress,classHash?,options?):Promise<ContractVersion>
Defined in: src/provider/interface.ts:399
Gets the contract version from the provided address
Parameters
contractAddress
string
classHash?
undefined
undefined
options?
getContractVersionOptions
- (optional) compiler - (default true) extract compiler version using type tactic from abi
- (optional) blockIdentifier - block identifier
Returns
Promise<ContractVersion>
Call Signature
abstractgetContractVersion(contractAddress,classHash,options?):Promise<ContractVersion>
Defined in: src/provider/interface.ts:413
Gets the contract version from the provided address
Parameters
contractAddress
undefined
undefined
classHash
options?
getContractVersionOptions
- (optional) compiler - (default true) extract compiler version using type tactic from abi
- (optional) blockIdentifier - block identifier
Returns
Promise<ContractVersion>
getBlockLatestAccepted()
abstractgetBlockLatestAccepted():Promise<{block_hash:string;block_number:number; }>
Defined in: src/provider/interface.ts:424
Get the most recent accepted block hash and number
Returns
Promise<{ block_hash: string; block_number: number; }>
Object containing block hash and number
getBlockNumber()
abstractgetBlockNumber():Promise<number>
Defined in: src/provider/interface.ts:430
Get the most recent accepted block number
Returns
Promise<number>
Number of the latest block
getBlockWithTxHashes()
abstractgetBlockWithTxHashes(blockIdentifier?):Promise<any>
Defined in: src/provider/interface.ts:437
Get block information with transaction hashes
Parameters
blockIdentifier?
block identifier
Returns
Promise<any>
Block with transaction hashes
getBlockWithTxs()
abstractgetBlockWithTxs(blockIdentifier?,options?):Promise<any>
Defined in: src/provider/interface.ts:446
Get block information with full transactions
Parameters
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()
abstractgetBlockWithReceipts(blockIdentifier?,options?):Promise<any>
Defined in: src/provider/interface.ts:458
Get block information with transaction receipts
Parameters
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()
abstractgetBlockTransactionsTraces(blockIdentifier?,options?):Promise<any>
Defined in: src/provider/interface.ts:470
Get transaction traces for all transactions in a block
Parameters
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()
abstractgetBlockTransactionCount(blockIdentifier?):Promise<number>
Defined in: src/provider/interface.ts:480
Get the number of transactions in a block
Parameters
blockIdentifier?
block identifier
Returns
Promise<number>
Transaction count
waitForBlock()
abstractwaitForBlock(blockIdentifier?,retryInterval?):Promise<void>
Defined in: src/provider/interface.ts:492
Pause execution until a specified block is created
Parameters
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()
abstractgetTransactionByHash(txHash,options?):Promise<TransactionWithHash>
Defined in: src/provider/interface.ts:505
Gets the transaction information from a tx hash (alias for getTransaction)
Parameters
txHash
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()
abstractgetTransactionByBlockIdAndIndex(blockIdentifier,index,options?):Promise<TransactionWithHash>
Defined in: src/provider/interface.ts:518
Gets transaction by block identifier and index
Parameters
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()
abstractgetTransactionTrace(txHash):Promise<TRANSACTION_TRACE|TRANSACTION_TRACE>
Defined in: src/provider/interface.ts:529
Gets the transaction trace
Parameters
txHash
transaction hash
Returns
Promise<TRANSACTION_TRACE | TRANSACTION_TRACE>
Transaction trace
getTransactionStatus()
abstractgetTransactionStatus(transactionHash):Promise<any>
Defined in: src/provider/interface.ts:538
Get the status of a transaction
Parameters
transactionHash
transaction hash