Skip to main content
Version: Next

Class: ProviderInterface

Hierarchy​

Constructors​

constructor​

• new ProviderInterface(): ProviderInterface

Returns​

ProviderInterface

Properties​

channel​

• Abstract channel: RpcChannel | RpcChannel

Defined in​

src/provider/interface.ts:37

Methods​

getChainId​

â–¸ getChainId(): Promise<StarknetChainId>

Gets the Starknet chain Id

Returns​

Promise<StarknetChainId>

the chain Id

Defined in​

src/provider/interface.ts:44


callContract​

â–¸ callContract(call, blockIdentifier?): Promise<CallContractResponse>

Calls a function on the Starknet contract.

Parameters​

NameTypeDescription
callCalltransaction to be called
blockIdentifier?BlockIdentifierblock identifier

Returns​

Promise<CallContractResponse>

the result of the function on the smart contract.

Defined in​

src/provider/interface.ts:53


getBlock​

â–¸ getBlock(blockIdentifier?): Promise<PendingBlock>

Gets the block information

Parameters​

NameTypeDescription
blockIdentifier?"pending"block identifier

Returns​

Promise<PendingBlock>

the block object

Defined in​

src/provider/interface.ts:64

â–¸ getBlock(blockIdentifier): Promise<Block>

Parameters​

NameType
blockIdentifier"latest"

Returns​

Promise<Block>

Defined in​

src/provider/interface.ts:65

â–¸ getBlock(blockIdentifier): Promise<GetBlockResponse>

Parameters​

NameType
blockIdentifierBlockIdentifier

Returns​

Promise<GetBlockResponse>

Defined in​

src/provider/interface.ts:66


getClassAt​

â–¸ getClassAt(contractAddress, blockIdentifier?): Promise<ContractClassResponse>

Gets the contract class of the deployed contract.

Parameters​

NameTypeDescription
contractAddressstringcontract address
blockIdentifier?BlockIdentifierblock identifier

Returns​

Promise<ContractClassResponse>

Contract class of compiled contract

Defined in​

src/provider/interface.ts:75


getL1GasPrice​

â–¸ getL1GasPrice(blockIdentifier): Promise<string>

Gets the price of l1 gas in the block

Parameters​

NameTypeDescription
blockIdentifierBlockIdentifierblock identifier

Returns​

Promise<string>

gas price of the block

Defined in​

src/provider/interface.ts:86


getL1MessageHash​

â–¸ getL1MessageHash(l2TxHash): Promise<string>

Get L1 message hash from L2 transaction hash

Parameters​

NameTypeDescription
l2TxHashBigNumberishL2 transaction hash

Returns​

Promise<string>

Hex string of L1 message hash

Example

In Sepolia Testnet :

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

Defined in​

src/provider/interface.ts:99


getClassHashAt​

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

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

Parameters​

NameTypeDescription
contractAddressstringcontract address
blockIdentifier?BlockIdentifierblock identifier

Returns​

Promise<string>

Class hash

Defined in​

src/provider/interface.ts:108


getClassByHash​

â–¸ getClassByHash(classHash): Promise<ContractClassResponse>

Returns the contract class deployed under the given class hash.

Parameters​

NameTypeDescription
classHashstringclass hash

Returns​

Promise<ContractClassResponse>

Contract class of compiled contract

Defined in​

src/provider/interface.ts:119


getNonceForAddress​

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

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

Parameters​

NameTypeDescription
contractAddressstringcontract address
blockIdentifier?BlockIdentifier-

Returns​

Promise<string>

the hex nonce

Defined in​

src/provider/interface.ts:127


getStorageAt​

â–¸ getStorageAt(contractAddress, key, blockIdentifier?): Promise<string>

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

Parameters​

NameTypeDescription
contractAddressstring
keyBigNumberishfrom getStorageVarAddress('<STORAGE_VARIABLE_NAME>') (WIP)
blockIdentifier?BlockIdentifierblock identifier

Returns​

Promise<string>

the value of the storage variable

Defined in​

src/provider/interface.ts:140


getTransaction​

â–¸ getTransaction(transactionHash): Promise<TransactionWithHash>

Gets the transaction information from a tx id.

Parameters​

NameType
transactionHashBigNumberish

Returns​

Promise<TransactionWithHash>

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

Defined in​

src/provider/interface.ts:152


getTransactionReceipt​

â–¸ getTransactionReceipt(transactionHash): Promise<GetTransactionReceiptResponse>

Gets the transaction receipt from a tx hash.

Parameters​

NameType
transactionHashBigNumberish

Returns​

Promise<GetTransactionReceiptResponse>

the transaction receipt object

Defined in​

src/provider/interface.ts:160


deployAccountContract​

â–¸ deployAccountContract(payload, details): Promise<DeployContractResponse>

Deploys a given compiled Account contract (json) to starknet

Parameters​

NameTypeDescription
payloadDeployAccountContractPayloadpayload to be deployed containing: - compiled contract code - constructor calldata - address salt
detailsInvocationsDetailsWithNonce-

Returns​

Promise<DeployContractResponse>

a confirmation of sending a transaction on the starknet contract

Defined in​

src/provider/interface.ts:173


invokeFunction​

â–¸ invokeFunction(invocation, details): Promise<{ transaction_hash: string }>

Invokes a function on starknet

Parameters​

NameTypeDescription
invocationInvocationthe invocation object containing: - contractAddress - the address of the contract - entrypoint - the entrypoint of the contract - calldata - (defaults to []) the calldata - signature - (defaults to []) the signature
detailsInvocationsDetailsWithNonceoptional details containing: - nonce - optional nonce - version - optional version - maxFee - optional maxFee

Returns​

Promise<{ transaction_hash: string }>

response from addTransaction

Deprecated

This method won't be supported as soon as fees are mandatory. Should not be used outside of Account class

Defined in​

src/provider/interface.ts:193


declareContract​

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

Declares a given compiled contract (json) to starknet

Parameters​

NameTypeDescription
transactionDeclareContractTransactiontransaction payload to be deployed containing: - compiled contract code - sender address - signature
detailsInvocationsDetailsWithNonceInvocation 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

Defined in​

src/provider/interface.ts:210


getEstimateFee​

â–¸ getEstimateFee(invocation, details, blockIdentifier?, skipValidate?): Promise<EstimateFeeResponse>

Estimates the fee for a given INVOKE transaction

Parameters​

NameTypeDescription
invocationInvocationthe invocation object containing: - contractAddress - the address of the contract - entrypoint - the entrypoint of the contract - calldata - (defaults to []) the calldata - signature - (defaults to []) the signature
detailsInvocationsDetailsWithNonceoptional details containing: - nonce - optional nonce - version - optional version
blockIdentifier?BlockIdentifier(optional) block identifier
skipValidate?boolean(optional) skip cairo validate method

Returns​

Promise<EstimateFeeResponse>

the estimated fee

Deprecated

Please use getInvokeEstimateFee or getDeclareEstimateFee instead. Should not be used outside of Account class

Defined in​

src/provider/interface.ts:231


getInvokeEstimateFee​

â–¸ getInvokeEstimateFee(invocation, details, blockIdentifier?, skipValidate?): Promise<EstimateFeeResponse>

Estimates the fee for a given INVOKE transaction

Parameters​

NameTypeDescription
invocationInvocationthe invocation object containing: - contractAddress - the address of the contract - entrypoint - the entrypoint of the contract - calldata - (defaults to []) the calldata - signature - (defaults to []) the signature
detailsInvocationsDetailsWithNonceoptional details containing: - nonce - optional nonce - version - optional version
blockIdentifier?BlockIdentifier(optional) block identifier
skipValidate?boolean(optional) skip cairo validate method

Returns​

Promise<EstimateFeeResponse>

the estimated fee

Defined in​

src/provider/interface.ts:253


getDeclareEstimateFee​

â–¸ getDeclareEstimateFee(transaction, details, blockIdentifier?, skipValidate?): Promise<EstimateFeeResponse>

Estimates the fee for a given DECLARE transaction

Parameters​

NameTypeDescription
transactionDeclareContractTransactiontransaction payload to be declared containing: - compiled contract code - sender address - signature - (defaults to []) the signature
detailsInvocationsDetailsWithNonceoptional details containing: - nonce - version - optional version - optional maxFee
blockIdentifier?BlockIdentifier(optional) block identifier
skipValidate?boolean(optional) skip cairo validate method

Returns​

Promise<EstimateFeeResponse>

the estimated fee

Defined in​

src/provider/interface.ts:275


getDeployAccountEstimateFee​

â–¸ getDeployAccountEstimateFee(transaction, details, blockIdentifier?, skipValidate?): Promise<EstimateFeeResponse>

Estimates the fee for a given DEPLOY_ACCOUNT transaction

Parameters​

NameTypeDescription
transactionDeployAccountContractTransactiontransaction payload to be deployed containing: - classHash - constructorCalldata - addressSalt - signature - (defaults to []) the signature
detailsInvocationsDetailsWithNonceoptional details containing: - nonce - version - optional version - optional maxFee
blockIdentifier?BlockIdentifier(optional) block identifier
skipValidate?boolean(optional) skip cairo validate method

Returns​

Promise<EstimateFeeResponse>

the estimated fee

Defined in​

src/provider/interface.ts:298


getEstimateFeeBulk​

â–¸ getEstimateFeeBulk(invocations, options?): Promise<EstimateFeeResponseBulk>

Estimates the fee for a list of INVOKE transaction

Parameters​

NameTypeDescription
invocationsAccountInvocationsAccountInvocations - Complete invocations array with account details
options?getEstimateFeeBulkOptionsgetEstimateFeeBulkOptions - (optional) blockIdentifier - BlockIdentifier

Returns​

Promise<EstimateFeeResponseBulk>

the estimated fee

Defined in​

src/provider/interface.ts:313


waitForTransaction​

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

Wait for the transaction to be accepted

Parameters​

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

Returns​

Promise<GetTransactionReceiptResponse>

GetTransactionReceiptResponse

Defined in​

src/provider/interface.ts:326


getSimulateTransaction​

â–¸ getSimulateTransaction(invocations, options?): Promise<SimulateTransactionResponse>

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

Parameters​

NameTypeDescription
invocationsAccountInvocationsAccountInvocations - Complete invocations array with account details
options?getSimulateTransactionOptionsgetSimulateTransactionOptions - (optional) blockIdentifier - block identifier - (optional) skipValidate - skip cairo validate method - (optional) skipExecute - skip cairo execute method

Returns​

Promise<SimulateTransactionResponse>

an array of transaction trace and estimated fee

Defined in​

src/provider/interface.ts:341


getStateUpdate​

â–¸ getStateUpdate(blockIdentifier?): Promise<StateUpdateResponse>

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

Parameters​

NameTypeDescription
blockIdentifier?BlockIdentifierblock identifier

Returns​

Promise<StateUpdateResponse>

StateUpdateResponse

Defined in​

src/provider/interface.ts:352


getContractVersion​

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

Gets the contract version from the provided address

Parameters​

NameTypeDescription
contractAddressstringstring
classHash?undefinedundefined
options?getContractVersionOptionsgetContractVersionOptions - (optional) compiler - (default true) extract compiler version using type tactic from abi - (optional) blockIdentifier - block identifier

Returns​

Promise<ContractVersion>

Defined in​

src/provider/interface.ts:362

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

Gets the contract version from the provided address

Parameters​

NameTypeDescription
contractAddressundefinedundefined
classHashstring
options?getContractVersionOptionsgetContractVersionOptions - (optional) compiler - (default true) extract compiler version using type tactic from abi - (optional) blockIdentifier - block identifier

Returns​

Promise<ContractVersion>

Defined in​

src/provider/interface.ts:376