Class JsonRpcProvider
-
- All Implemented Interfaces:
-
com.swmansion.starknet.provider.Provider
public final class JsonRpcProvider implements Provider
A provider for interacting with Starknet using JSON-RPC. You should reuse it in your application to share the httpService or provide it with your own httpService.
-
-
Constructor Summary
Constructors Constructor Description JsonRpcProvider(String url, Boolean ignoreUnknownJsonKeys)
JsonRpcProvider(String url, HttpService httpService)
JsonRpcProvider(String url)
JsonRpcProvider(String url, HttpService httpService, Boolean ignoreUnknownJsonKeys)
-
Method Summary
-
-
Constructor Detail
-
JsonRpcProvider
JsonRpcProvider(String url, HttpService httpService)
-
JsonRpcProvider
JsonRpcProvider(String url)
-
JsonRpcProvider
JsonRpcProvider(String url, HttpService httpService, Boolean ignoreUnknownJsonKeys)
- Parameters:
url
- url of the service providing a rpc interfacehttpService
- service used for making http requests
-
-
Method Detail
-
batchRequestsAny
final HttpBatchRequest<StarknetResponse> batchRequestsAny(List<HttpRequest<out StarknetResponse>> requests)
Batch multiple various calls into a single RPC request
- Parameters:
requests
- list of requests to be batched together
-
batchRequestsAny
final HttpBatchRequest<StarknetResponse> batchRequestsAny(HttpRequest<out StarknetResponse> requests)
Batch multiple various calls into a single RPC request
- Parameters:
requests
- requests to be batched together
-
batchRequests
final <T extends StarknetResponse> HttpBatchRequest<T> batchRequests(List<HttpRequest<T>> requests)
Batch multiple calls into a single RPC request
- Parameters:
requests
- list of requests to be batched together
-
batchRequests
final <T extends StarknetResponse> HttpBatchRequest<T> batchRequests(HttpRequest<T> requests)
Batch multiple calls into a single RPC request
- Parameters:
requests
- requests to be batched together
-
getSpecVersion
HttpRequest<StringResponse> getSpecVersion()
-
callContract
HttpRequest<FeltArray> callContract(Call call, BlockTag blockTag)
- Parameters:
call
- a call to be made
-
callContract
HttpRequest<FeltArray> callContract(Call call, Felt blockHash)
- Parameters:
call
- a call to be madeblockHash
- a hash of the block in respect to what the call will be made
-
callContract
HttpRequest<FeltArray> callContract(Call call, Integer blockNumber)
- Parameters:
call
- a call to be madeblockNumber
- a number of the block in respect to what the call will be made
-
callContract
HttpRequest<FeltArray> callContract(Call call)
Calls a contract deployed on Starknet.
Calls a contract deployed on Starknet in the latest block.
- Parameters:
call
- a call to be made
-
deployAccount
HttpRequest<DeployAccountResponse> deployAccount(DeployAccountTransactionV1 payload)
Deploy an account contract using version 1 transaction.
Deploy a new account contract on Starknet.
- Parameters:
payload
- deploy account transaction version 1 payload
-
deployAccount
HttpRequest<DeployAccountResponse> deployAccount(DeployAccountTransactionV3 payload)
Deploy an account contract using version 3 transaction.
Deploy a new account contract on Starknet.
- Parameters:
payload
- deploy account transaction version 3 payload
-
getStorageAt
HttpRequest<Felt> getStorageAt(Felt contractAddress, Felt key, BlockTag blockTag)
- Parameters:
contractAddress
- an address of the contractkey
- an address of the storage variable inside contractblockTag
- The tag of the requested block.
-
getStorageAt
HttpRequest<Felt> getStorageAt(Felt contractAddress, Felt key, Felt blockHash)
Get a value of storage var.
Get a value of a storage variable of contract at the provided address.
- Parameters:
contractAddress
- an address of the contractkey
- an address of the storage variable inside contractblockHash
- a hash of the block in respect to what the query will be made
-
getStorageAt
HttpRequest<Felt> getStorageAt(Felt contractAddress, Felt key, Integer blockNumber)
Get a value of storage var.
Get a value of a storage variable of contract at the provided address.
- Parameters:
contractAddress
- an address of the contractkey
- an address of the storage variable inside contractblockNumber
- a number of the block in respect to what the query will be made
-
getStorageAt
HttpRequest<Felt> getStorageAt(Felt contractAddress, Felt key)
Get a value of storage var.
Get a value of a storage variable of contract at the provided address and in the latest block.
- Parameters:
contractAddress
- an address of the contractkey
- an address of the storage variable inside contract
-
getStorageAt
Request<Felt> getStorageAt(Felt contractAddress, String key, BlockTag blockTag)
- Parameters:
contractAddress
- an address of the contractkey
- an address of the storage variable inside contractblockTag
- The tag of the requested block.
-
getStorageAt
Request<Felt> getStorageAt(Felt contractAddress, String key, Felt blockHash)
Get a value of storage var.
Get a value of a storage variable of contract at the provided address.
- Parameters:
contractAddress
- an address of the contractkey
- an address of the storage variable inside contractblockHash
- a hash of the block in respect to what the query will be made
-
getStorageAt
Request<Felt> getStorageAt(Felt contractAddress, String key, Integer blockNumber)
Get a value of storage var.
Get a value of a storage variable of contract at the provided address.
- Parameters:
contractAddress
- an address of the contractkey
- an address of the storage variable inside contractblockNumber
- a number of the block in respect to what the query will be made
-
getStorageAt
Request<Felt> getStorageAt(Felt contractAddress, String key)
Get a value of storage var.
Get a value of a storage variable of contract at the provided address and in the latest block.
- Parameters:
contractAddress
- an address of the contractkey
- an address of the storage variable inside contract
-
getTransaction
HttpRequest<Transaction> getTransaction(Felt transactionHash)
- Parameters:
transactionHash
- a hash of sent transaction
-
getTransactionReceipt
HttpRequest<out TransactionReceipt> getTransactionReceipt(Felt transactionHash)
- Parameters:
transactionHash
- a hash of sent transaction
-
getTransactionStatus
HttpRequest<GetTransactionStatusResponse> getTransactionStatus(Felt transactionHash)
- Parameters:
transactionHash
- a hash of sent transaction
-
invokeFunction
HttpRequest<InvokeFunctionResponse> invokeFunction(InvokeTransactionV1 payload)
- Parameters:
payload
- invoke function version 1 payload
-
invokeFunction
HttpRequest<InvokeFunctionResponse> invokeFunction(InvokeTransactionV3 payload)
- Parameters:
payload
- invoke function version 3 payload
-
getClass
HttpRequest<ContractClassBase> getClass(Felt classHash)
- Parameters:
classHash
- The hash of the requested contract class.
-
getClass
HttpRequest<ContractClassBase> getClass(Felt classHash, Felt blockHash)
- Parameters:
classHash
- The hash of the requested contract class.blockHash
- The hash of requested block.
-
getClass
HttpRequest<ContractClassBase> getClass(Felt classHash, Integer blockNumber)
- Parameters:
classHash
- The hash of the requested contract class.blockNumber
- The number of requested block.
-
getClass
HttpRequest<ContractClassBase> getClass(Felt classHash, BlockTag blockTag)
- Parameters:
classHash
- The hash of the requested contract class.blockTag
- The tag of requested block.
-
getClassAt
HttpRequest<ContractClassBase> getClassAt(Felt contractAddress, Felt blockHash)
- Parameters:
contractAddress
- The address of the contract whose class definition will be returned.blockHash
- The hash of the requested block.
-
getClassAt
HttpRequest<ContractClassBase> getClassAt(Felt contractAddress, Integer blockNumber)
- Parameters:
contractAddress
- The address of the contract whose class definition will be returned.blockNumber
- The number of the requested block.
-
getClassAt
HttpRequest<ContractClassBase> getClassAt(Felt contractAddress, BlockTag blockTag)
- Parameters:
contractAddress
- The address of the contract whose class definition will be returned.blockTag
- The tag of the requested block.
-
getClassAt
HttpRequest<ContractClassBase> getClassAt(Felt contractAddress)
- Parameters:
contractAddress
- The address of the contract whose class definition will be returned.
-
getClassHashAt
HttpRequest<Felt> getClassHashAt(Felt contractAddress, Felt blockHash)
Get the contract class hash.
Get the contract class hash in the given block for the contract deployed at the given address.
- Parameters:
contractAddress
- The address of the contract whose class definition will be returned.blockHash
- The hash of the requested block.
-
getClassHashAt
HttpRequest<Felt> getClassHashAt(Felt contractAddress, Integer blockNumber)
Get the contract class hash.
Get the contract class hash in the given block for the contract deployed at the given address.
- Parameters:
contractAddress
- The address of the contract whose class definition will be returned.blockNumber
- The number of the requested block.
-
getClassHashAt
HttpRequest<Felt> getClassHashAt(Felt contractAddress, BlockTag blockTag)
- Parameters:
contractAddress
- The address of the contract whose class definition will be returned.blockTag
- The tag of the requested block.
-
getClassHashAt
HttpRequest<Felt> getClassHashAt(Felt contractAddress)
- Parameters:
contractAddress
- The address of the contract whose class definition will be returned.
-
declareContract
HttpRequest<DeclareResponse> declareContract(DeclareTransactionV2 payload)
Declare contract using version 2 transaction.
Declare a contract on Starknet using version 2 transaction.
- Parameters:
payload
- declare transaction version 2 payload
-
declareContract
HttpRequest<DeclareResponse> declareContract(DeclareTransactionV3 payload)
Declare contract using version 3 transaction.
Declare a contract on Starknet using version 3 transaction.
- Parameters:
payload
- declare transaction version 3 payload
-
getBlockNumber
HttpRequest<IntResponse> getBlockNumber()
-
getBlockHashAndNumber
HttpRequest<GetBlockHashAndNumberResponse> getBlockHashAndNumber()
-
getBlockTransactionCount
HttpRequest<IntResponse> getBlockTransactionCount(BlockTag blockTag)
- Parameters:
blockTag
- The tag of the block.
-
getBlockTransactionCount
HttpRequest<IntResponse> getBlockTransactionCount(Felt blockHash)
- Parameters:
blockHash
- The hash of the block.
-
getBlockTransactionCount
HttpRequest<IntResponse> getBlockTransactionCount(Integer blockNumber)
- Parameters:
blockNumber
- The number of the block.
-
getEvents
HttpRequest<GetEventsResult> getEvents(GetEventsPayload payload)
- Parameters:
payload
- get events payload
-
getEstimateFee
HttpRequest<EstimateFeeResponseList> getEstimateFee(List<ExecutableTransaction> payload, Felt blockHash, Set<SimulationFlagForEstimateFee> simulationFlags)
Estimate a fee.
Estimate a fee for a provided transaction list.
- Parameters:
payload
- transactions, for which the fee is to be estimated.blockHash
- a hash of the block in respect to what the query will be madesimulationFlags
- set of flags to be used for simulation.
-
getEstimateFee
HttpRequest<EstimateFeeResponseList> getEstimateFee(List<ExecutableTransaction> payload, Felt blockHash)
Estimate a fee.
Estimate a fee for a provided transaction list.
- Parameters:
payload
- transactions, for which the fee is to be estimated.blockHash
- a hash of the block in respect to what the query will be made
-
getEstimateFee
HttpRequest<EstimateFeeResponseList> getEstimateFee(List<ExecutableTransaction> payload, Integer blockNumber, Set<SimulationFlagForEstimateFee> simulationFlags)
Estimate a fee.
Estimate a fee for a provided transaction list.
- Parameters:
payload
- transactions, for which the fee is to be estimated.blockNumber
- a number of the block in respect to what the query will be madesimulationFlags
- set of flags to be used for simulation.
-
getEstimateFee
HttpRequest<EstimateFeeResponseList> getEstimateFee(List<ExecutableTransaction> payload, Integer blockNumber)
Estimate a fee.
Estimate a fee for a provided transaction list.
- Parameters:
payload
- transactions, for which the fee is to be estimated.blockNumber
- a number of the block in respect to what the query will be made
-
getEstimateFee
HttpRequest<EstimateFeeResponseList> getEstimateFee(List<ExecutableTransaction> payload, BlockTag blockTag, Set<SimulationFlagForEstimateFee> simulationFlags)
- Parameters:
payload
- transactions, for which the fee is to be estimated.blockTag
- a tag of the block in respect to what the query will be madesimulationFlags
- set of flags to be used for simulation.
-
getEstimateFee
HttpRequest<EstimateFeeResponseList> getEstimateFee(List<ExecutableTransaction> payload, BlockTag blockTag)
Estimate a fee.
Estimate a fee for a provided transaction list.
- Parameters:
payload
- transactions, for which the fee is to be estimated.blockTag
- a tag of the block in respect to what the query will be made
-
getEstimateFee
HttpRequest<EstimateFeeResponseList> getEstimateFee(List<ExecutableTransaction> payload, Set<SimulationFlagForEstimateFee> simulationFlags)
- Parameters:
payload
- transactions, for which the fee is to be estimated.simulationFlags
- set of flags to be used for simulation
-
getEstimateFee
HttpRequest<EstimateFeeResponseList> getEstimateFee(List<ExecutableTransaction> payload)
- Parameters:
payload
- transaction, for which the fee is to be estimated.
-
getEstimateMessageFee
HttpRequest<EstimateFeeResponse> getEstimateMessageFee(MessageL1ToL2 message, Felt blockHash)
Estimate a message fee.
Estimate the L2 fee of a provided message sent on L1.
- Parameters:
message
- message, for which the fee is to be estimated.blockHash
- a hash of the block in respect to what the query will be made
-
getEstimateMessageFee
HttpRequest<EstimateFeeResponse> getEstimateMessageFee(MessageL1ToL2 message, Integer blockNumber)
Estimate a message fee.
Estimate the L2 fee of a provided message sent on L1.
- Parameters:
message
- message, for which the fee is to be estimated.blockNumber
- a number of the block in respect to what the query will be made
-
getEstimateMessageFee
HttpRequest<EstimateFeeResponse> getEstimateMessageFee(MessageL1ToL2 message, BlockTag blockTag)
- Parameters:
message
- message, for which the fee is to be estimated.blockTag
- a tag of the block in respect to what the query will be made
-
getNonce
HttpRequest<Felt> getNonce(Felt contractAddress)
Get a nonce.
Get a nonce of an account contract of a given address for pending block.
- Parameters:
contractAddress
- address of account contract
-
getNonce
HttpRequest<Felt> getNonce(Felt contractAddress, BlockTag blockTag)
- Parameters:
contractAddress
- address of account contractblockTag
- block tag used for returning this value
-
getNonce
HttpRequest<Felt> getNonce(Felt contractAddress, Integer blockNumber)
- Parameters:
contractAddress
- address of account contractblockNumber
- block number used for returning this value
-
getNonce
HttpRequest<Felt> getNonce(Felt contractAddress, Felt blockHash)
- Parameters:
contractAddress
- address of account contractblockHash
- block hash used for returning this value
-
getSyncing
HttpRequest<Syncing> getSyncing()
-
getChainId
HttpRequest<StarknetChainId> getChainId()
-
getBlockWithTxs
HttpRequest<BlockWithTransactions> getBlockWithTxs(BlockTag blockTag)
- Parameters:
blockTag
- a tag of the requested block
-
getBlockWithTxs
HttpRequest<BlockWithTransactions> getBlockWithTxs(Felt blockHash)
- Parameters:
blockHash
- a hash of the requested block
-
getBlockWithTxs
HttpRequest<BlockWithTransactions> getBlockWithTxs(Integer blockNumber)
- Parameters:
blockNumber
- a number of the requested block
-
getBlockWithTxHashes
HttpRequest<BlockWithTransactionHashes> getBlockWithTxHashes(BlockTag blockTag)
- Parameters:
blockTag
- a tag of the requested block
-
getBlockWithTxHashes
HttpRequest<BlockWithTransactionHashes> getBlockWithTxHashes(Felt blockHash)
- Parameters:
blockHash
- a hash of the requested block
-
getBlockWithTxHashes
HttpRequest<BlockWithTransactionHashes> getBlockWithTxHashes(Integer blockNumber)
- Parameters:
blockNumber
- a number of the requested block
-
getBlockWithReceipts
HttpRequest<BlockWithReceipts> getBlockWithReceipts(BlockTag blockTag)
- Parameters:
blockTag
- a tag of the requested block
-
getBlockWithReceipts
HttpRequest<BlockWithReceipts> getBlockWithReceipts(Felt blockHash)
- Parameters:
blockHash
- a hash of the requested block
-
getBlockWithReceipts
HttpRequest<BlockWithReceipts> getBlockWithReceipts(Integer blockNumber)
- Parameters:
blockNumber
- a number of the requested block
-
getStateUpdate
HttpRequest<StateUpdate> getStateUpdate(BlockTag blockTag)
- Parameters:
blockTag
- a tag of the requested block
-
getStateUpdate
HttpRequest<StateUpdate> getStateUpdate(Felt blockHash)
- Parameters:
blockHash
- a hash of the requested block
-
getStateUpdate
HttpRequest<StateUpdate> getStateUpdate(Integer blockNumber)
- Parameters:
blockNumber
- a number of the requested block
-
getTransactionByBlockIdAndIndex
HttpRequest<Transaction> getTransactionByBlockIdAndIndex(BlockTag blockTag, Integer index)
- Parameters:
blockTag
- a tag of the requested block
-
getTransactionByBlockIdAndIndex
HttpRequest<Transaction> getTransactionByBlockIdAndIndex(Felt blockHash, Integer index)
- Parameters:
blockHash
- a hash of the requested block
-
getTransactionByBlockIdAndIndex
HttpRequest<Transaction> getTransactionByBlockIdAndIndex(Integer blockNumber, Integer index)
- Parameters:
blockNumber
- a number of the requested block
-
simulateTransactions
HttpRequest<SimulatedTransactionList> simulateTransactions(List<ExecutableTransaction> transactions, BlockTag blockTag, Set<SimulationFlag> simulationFlags)
- Parameters:
transactions
- list of transactions to be simulatedblockTag
- tag of the block that should be used for simulationsimulationFlags
- set of flags to be used for simulation
-
simulateTransactions
HttpRequest<SimulatedTransactionList> simulateTransactions(List<ExecutableTransaction> transactions, Integer blockNumber, Set<SimulationFlag> simulationFlags)
Simulate executing a list of transactions
- Parameters:
transactions
- list of transactions to be simulatedblockNumber
- number of the block that should be used for simulationsimulationFlags
- set of flags to be used for simulation
-
simulateTransactions
HttpRequest<SimulatedTransactionList> simulateTransactions(List<ExecutableTransaction> transactions, Felt blockHash, Set<SimulationFlag> simulationFlags)
Simulate executing a list of transactions
- Parameters:
transactions
- list of transactions to be simulatedblockHash
- hash of the block that should be used for simulationsimulationFlags
- set of flags to be used for simulation
-
-
-
-