Package org.web3j.protocol.core
Class JsonRpc2_0Web3j
java.lang.Object
org.web3j.protocol.core.JsonRpc2_0Web3j
- Direct Known Subclasses:
JsonRpc2_0Admin
JSON-RPC 2.0 factory implementation.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionJsonRpc2_0Web3j(Web3jService web3jService) JsonRpc2_0Web3j(Web3jService web3jService, long pollingInterval, ScheduledExecutorService scheduledExecutorService) -
Method Summary
Modifier and TypeMethodDescriptionadminAddPeer(String url) adminRemovePeer(String url) io.reactivex.Flowable<EthBlock>blockFlowable(boolean fullTransactionObjects) Create anFlowableinstance that emits newly created blocks on the blockchain.dbGetString(String databaseName, String keyName) dbPutString(String databaseName, String keyName, String stringToStore) io.reactivex.Flowable<String>Create an Flowable to emit block hashes.ethCall(Transaction transaction, DefaultBlockParameter defaultBlockParameter) ethCompileLLL(String sourceCode) ethCompileSerpent(String sourceCode) ethCompileSolidity(String sourceCode) ethEstimateGas(Transaction transaction) ethFeeHistory(int blockCount, DefaultBlockParameter newestBlock, List<Double> rewardPercentiles) ethGetBalance(String address, DefaultBlockParameter defaultBlockParameter) ethGetBlockByHash(String blockHash, boolean returnFullTransactionObjects) ethGetBlockByNumber(DefaultBlockParameter defaultBlockParameter, boolean returnFullTransactionObjects) ethGetBlockReceipts(DefaultBlockParameter defaultBlockParameter) ethGetBlockTransactionCountByHash(String blockHash) ethGetBlockTransactionCountByNumber(DefaultBlockParameter defaultBlockParameter) ethGetCode(String address, DefaultBlockParameter defaultBlockParameter) ethGetFilterChanges(BigInteger filterId) ethGetFilterLogs(BigInteger filterId) ethGetLogs(EthFilter ethFilter) ethGetProof(String address, List<String> storageKeys, String quantity) ethGetStorageAt(String address, BigInteger position, DefaultBlockParameter defaultBlockParameter) ethGetTransactionByBlockHashAndIndex(String blockHash, BigInteger transactionIndex) ethGetTransactionByBlockNumberAndIndex(DefaultBlockParameter defaultBlockParameter, BigInteger transactionIndex) ethGetTransactionByHash(String transactionHash) ethGetTransactionCount(String address, DefaultBlockParameter defaultBlockParameter) ethGetTransactionReceipt(String transactionHash) ethGetUncleByBlockHashAndIndex(String blockHash, BigInteger transactionIndex) ethGetUncleByBlockNumberAndIndex(DefaultBlockParameter defaultBlockParameter, BigInteger uncleIndex) ethGetUncleCountByBlockHash(String blockHash) ethGetUncleCountByBlockNumber(DefaultBlockParameter defaultBlockParameter) io.reactivex.Flowable<Log>ethLogFlowable(EthFilter ethFilter) Create an flowable to filter for specific log events on the blockchain.ethNewFilter(EthFilter ethFilter) io.reactivex.Flowable<String>Create an Flowable to emit pending transactions, i.e.ethSendRawTransaction(String signedTransactionData) ethSendTransaction(Transaction transaction) ethSubmitHashrate(String hashrate, String clientId) ethSubmitWork(String nonce, String headerPowHash, String mixDigest) ethUninstallFilter(BigInteger filterId) io.reactivex.Flowable<LogNotification>logsNotifications(List<String> addresses, List<String> topics) Creates aaFlowableinstance that emits notifications for logs included in new imported blocks.newBatch()Create a newBatchRequest.io.reactivex.Flowable<NewHeadsNotification>Creates aFlowableinstance that emits a notification when a new header is appended to a chain, including chain reorganizations.io.reactivex.Flowable<Transaction>Create anFlowableinstance to emit all pending transactions that have yet to be placed into a block on the blockchain.io.reactivex.Flowable<EthBlock>replayPastAndFutureBlocksFlowable(DefaultBlockParameter startBlock, boolean fullTransactionObjects) Creates aFlowableinstance that emits all blocks from the requested block number to the most current.io.reactivex.Flowable<Transaction>As perWeb3jRx.replayPastAndFutureBlocksFlowable(DefaultBlockParameter, boolean), except that all transactions contained within the blocks are emitted.io.reactivex.Flowable<EthBlock>replayPastBlocksFlowable(DefaultBlockParameter startBlock, boolean fullTransactionObjects) Creates aFlowableinstance that emits all blocks from the requested block number to the most current.io.reactivex.Flowable<EthBlock>replayPastBlocksFlowable(DefaultBlockParameter startBlock, boolean fullTransactionObjects, io.reactivex.Flowable<EthBlock> onCompleteFlowable) Create aFlowableinstance that emits all transactions from the blockchain starting with a provided block number.io.reactivex.Flowable<EthBlock>replayPastBlocksFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock, boolean fullTransactionObjects) Create anFlowableinstance that emits all blocks from the blockchain contained within the requested range.io.reactivex.Flowable<EthBlock>replayPastBlocksFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock, boolean fullTransactionObjects, boolean ascending) Create anFlowableinstance that emits all blocks from the blockchain contained within the requested range.io.reactivex.Flowable<Transaction>replayPastTransactionsFlowable(DefaultBlockParameter startBlock) Creates aFlowableinstance that emits all transactions from the requested block number to the most current.io.reactivex.Flowable<Transaction>replayPastTransactionsFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) Create aFlowableinstance that emits all transactions from the blockchain contained within the requested range.shhAddToGroup(String identityAddress) shhGetFilterChanges(BigInteger filterId) shhGetMessages(BigInteger filterId) shhHasIdentity(String identityAddress) shhNewFilter(ShhFilter shhFilter) shhUninstallFilter(BigInteger filterId) voidshutdown()Shutdowns a Web3j instance and closes opened resources.io.reactivex.Flowable<Transaction>Create anFlowableinstance to emit all new transactions as they are confirmed on the blockchain.
-
Field Details
-
DEFAULT_BLOCK_TIME
public static final int DEFAULT_BLOCK_TIME- See Also:
-
web3jService
-
-
Constructor Details
-
JsonRpc2_0Web3j
-
JsonRpc2_0Web3j
public JsonRpc2_0Web3j(Web3jService web3jService, long pollingInterval, ScheduledExecutorService scheduledExecutorService)
-
-
Method Details
-
web3ClientVersion
- Specified by:
web3ClientVersionin interfaceEthereum
-
web3Sha3
-
netVersion
- Specified by:
netVersionin interfaceEthereum
-
netListening
- Specified by:
netListeningin interfaceEthereum
-
netPeerCount
- Specified by:
netPeerCountin interfaceEthereum
-
adminNodeInfo
- Specified by:
adminNodeInfoin interfaceEthereum
-
adminPeers
- Specified by:
adminPeersin interfaceEthereum
-
adminAddPeer
- Specified by:
adminAddPeerin interfaceEthereum
-
adminRemovePeer
- Specified by:
adminRemovePeerin interfaceEthereum
-
adminDataDir
- Specified by:
adminDataDirin interfaceEthereum
-
ethProtocolVersion
- Specified by:
ethProtocolVersionin interfaceEthereum
-
ethChainId
- Specified by:
ethChainIdin interfaceEthereum
-
ethCoinbase
- Specified by:
ethCoinbasein interfaceEthereum
-
ethSyncing
- Specified by:
ethSyncingin interfaceEthereum
-
ethMining
-
ethHashrate
- Specified by:
ethHashratein interfaceEthereum
-
ethGasPrice
- Specified by:
ethGasPricein interfaceEthereum
-
ethMaxPriorityFeePerGas
- Specified by:
ethMaxPriorityFeePerGasin interfaceEthereum
-
ethBaseFee
- Specified by:
ethBaseFeein interfaceEthereum
-
ethFeeHistory
public Request<?,EthFeeHistory> ethFeeHistory(int blockCount, DefaultBlockParameter newestBlock, List<Double> rewardPercentiles) - Specified by:
ethFeeHistoryin interfaceEthereum
-
ethAccounts
- Specified by:
ethAccountsin interfaceEthereum
-
ethBlockNumber
- Specified by:
ethBlockNumberin interfaceEthereum
-
ethGetBalance
public Request<?,EthGetBalance> ethGetBalance(String address, DefaultBlockParameter defaultBlockParameter) - Specified by:
ethGetBalancein interfaceEthereum
-
ethGetStorageAt
public Request<?,EthGetStorageAt> ethGetStorageAt(String address, BigInteger position, DefaultBlockParameter defaultBlockParameter) - Specified by:
ethGetStorageAtin interfaceEthereum
-
ethGetTransactionCount
public Request<?,EthGetTransactionCount> ethGetTransactionCount(String address, DefaultBlockParameter defaultBlockParameter) - Specified by:
ethGetTransactionCountin interfaceEthereum
-
ethGetBlockTransactionCountByHash
public Request<?,EthGetBlockTransactionCountByHash> ethGetBlockTransactionCountByHash(String blockHash) - Specified by:
ethGetBlockTransactionCountByHashin interfaceEthereum
-
ethGetBlockTransactionCountByNumber
public Request<?,EthGetBlockTransactionCountByNumber> ethGetBlockTransactionCountByNumber(DefaultBlockParameter defaultBlockParameter) - Specified by:
ethGetBlockTransactionCountByNumberin interfaceEthereum
-
ethGetUncleCountByBlockHash
- Specified by:
ethGetUncleCountByBlockHashin interfaceEthereum
-
ethGetUncleCountByBlockNumber
public Request<?,EthGetUncleCountByBlockNumber> ethGetUncleCountByBlockNumber(DefaultBlockParameter defaultBlockParameter) - Specified by:
ethGetUncleCountByBlockNumberin interfaceEthereum
-
ethGetCode
public Request<?,EthGetCode> ethGetCode(String address, DefaultBlockParameter defaultBlockParameter) - Specified by:
ethGetCodein interfaceEthereum
-
ethSign
-
ethSendTransaction
- Specified by:
ethSendTransactionin interfaceEthereum
-
ethSendRawTransaction
- Specified by:
ethSendRawTransactionin interfaceEthereum
-
ethCall
public Request<?,EthCall> ethCall(Transaction transaction, DefaultBlockParameter defaultBlockParameter) -
ethEstimateGas
- Specified by:
ethEstimateGasin interfaceEthereum
-
ethGetBlockByHash
public Request<?,EthBlock> ethGetBlockByHash(String blockHash, boolean returnFullTransactionObjects) - Specified by:
ethGetBlockByHashin interfaceEthereum
-
ethGetBlockByNumber
public Request<?,EthBlock> ethGetBlockByNumber(DefaultBlockParameter defaultBlockParameter, boolean returnFullTransactionObjects) - Specified by:
ethGetBlockByNumberin interfaceEthereum
-
ethGetTransactionByHash
- Specified by:
ethGetTransactionByHashin interfaceEthereum
-
ethGetTransactionByBlockHashAndIndex
public Request<?,EthTransaction> ethGetTransactionByBlockHashAndIndex(String blockHash, BigInteger transactionIndex) - Specified by:
ethGetTransactionByBlockHashAndIndexin interfaceEthereum
-
ethGetTransactionByBlockNumberAndIndex
public Request<?,EthTransaction> ethGetTransactionByBlockNumberAndIndex(DefaultBlockParameter defaultBlockParameter, BigInteger transactionIndex) - Specified by:
ethGetTransactionByBlockNumberAndIndexin interfaceEthereum
-
ethGetTransactionReceipt
- Specified by:
ethGetTransactionReceiptin interfaceEthereum
-
ethGetBlockReceipts
public Request<?,EthGetBlockReceipts> ethGetBlockReceipts(DefaultBlockParameter defaultBlockParameter) - Specified by:
ethGetBlockReceiptsin interfaceEthereum
-
ethGetUncleByBlockHashAndIndex
public Request<?,EthBlock> ethGetUncleByBlockHashAndIndex(String blockHash, BigInteger transactionIndex) - Specified by:
ethGetUncleByBlockHashAndIndexin interfaceEthereum
-
ethGetUncleByBlockNumberAndIndex
public Request<?,EthBlock> ethGetUncleByBlockNumberAndIndex(DefaultBlockParameter defaultBlockParameter, BigInteger uncleIndex) - Specified by:
ethGetUncleByBlockNumberAndIndexin interfaceEthereum
-
ethGetCompilers
- Specified by:
ethGetCompilersin interfaceEthereum
-
ethCompileLLL
- Specified by:
ethCompileLLLin interfaceEthereum
-
ethCompileSolidity
- Specified by:
ethCompileSolidityin interfaceEthereum
-
ethCompileSerpent
- Specified by:
ethCompileSerpentin interfaceEthereum
-
ethNewFilter
- Specified by:
ethNewFilterin interfaceEthereum
-
ethNewBlockFilter
- Specified by:
ethNewBlockFilterin interfaceEthereum
-
ethNewPendingTransactionFilter
- Specified by:
ethNewPendingTransactionFilterin interfaceEthereum
-
ethUninstallFilter
- Specified by:
ethUninstallFilterin interfaceEthereum
-
ethGetFilterChanges
- Specified by:
ethGetFilterChangesin interfaceEthereum
-
ethGetFilterLogs
- Specified by:
ethGetFilterLogsin interfaceEthereum
-
ethGetLogs
- Specified by:
ethGetLogsin interfaceEthereum
-
ethGetProof
public Request<?,EthGetProof> ethGetProof(String address, List<String> storageKeys, String quantity) - Specified by:
ethGetProofin interfaceEthereum
-
ethGetWork
- Specified by:
ethGetWorkin interfaceEthereum
-
ethSubmitWork
- Specified by:
ethSubmitWorkin interfaceEthereum
-
ethSubmitHashrate
- Specified by:
ethSubmitHashratein interfaceEthereum
-
dbPutString
public Request<?,DbPutString> dbPutString(String databaseName, String keyName, String stringToStore) - Specified by:
dbPutStringin interfaceEthereum
-
dbGetString
- Specified by:
dbGetStringin interfaceEthereum
-
dbPutHex
-
dbGetHex
-
shhPost
-
shhVersion
- Specified by:
shhVersionin interfaceEthereum
-
shhNewIdentity
- Specified by:
shhNewIdentityin interfaceEthereum
-
shhHasIdentity
- Specified by:
shhHasIdentityin interfaceEthereum
-
shhNewGroup
- Specified by:
shhNewGroupin interfaceEthereum
-
shhAddToGroup
- Specified by:
shhAddToGroupin interfaceEthereum
-
shhNewFilter
- Specified by:
shhNewFilterin interfaceEthereum
-
shhUninstallFilter
- Specified by:
shhUninstallFilterin interfaceEthereum
-
shhGetFilterChanges
- Specified by:
shhGetFilterChangesin interfaceEthereum
-
shhGetMessages
- Specified by:
shhGetMessagesin interfaceEthereum
-
txPoolStatus
- Specified by:
txPoolStatusin interfaceEthereum
-
newHeadsNotifications
Description copied from interface:Web3jRxCreates aFlowableinstance that emits a notification when a new header is appended to a chain, including chain reorganizations.- Specified by:
newHeadsNotificationsin interfaceWeb3jRx- Returns:
- a
Flowableinstance that emits a notification for every new header
-
logsNotifications
public io.reactivex.Flowable<LogNotification> logsNotifications(List<String> addresses, List<String> topics) Description copied from interface:Web3jRxCreates aaFlowableinstance that emits notifications for logs included in new imported blocks.- Specified by:
logsNotificationsin interfaceWeb3jRx- Parameters:
addresses- only return logs from this list of address. Return logs from all addresses if the list is emptytopics- only return logs that match specified topics. Returns logs for all topics if the list is empty- Returns:
- a
Flowableinstance that emits logs included in new blocks
-
ethBlockHashFlowable
Description copied from interface:Web3jRxCreate an Flowable to emit block hashes.- Specified by:
ethBlockHashFlowablein interfaceWeb3jRx- Returns:
- a
Flowableinstance that emits all new block hashes as new blocks are created on the blockchain
-
ethPendingTransactionHashFlowable
Description copied from interface:Web3jRxCreate an Flowable to emit pending transactions, i.e. those transactions that have been submitted by a node, but don't yet form part of a block (haven't been mined yet).- Specified by:
ethPendingTransactionHashFlowablein interfaceWeb3jRx- Returns:
- a
Flowableinstance to emit pending transaction hashes.
-
ethLogFlowable
Description copied from interface:Web3jRxCreate an flowable to filter for specific log events on the blockchain.- Specified by:
ethLogFlowablein interfaceWeb3jRx- Parameters:
ethFilter- filter criteria- Returns:
- a
Flowableinstance that emits all Log events matching the filter
-
transactionFlowable
Description copied from interface:Web3jRxCreate anFlowableinstance to emit all new transactions as they are confirmed on the blockchain. i.e. they have been mined and are incorporated into a block.- Specified by:
transactionFlowablein interfaceWeb3jRx- Returns:
- a
Flowableinstance to emit new transactions on the blockchain
-
pendingTransactionFlowable
Description copied from interface:Web3jRxCreate anFlowableinstance to emit all pending transactions that have yet to be placed into a block on the blockchain.- Specified by:
pendingTransactionFlowablein interfaceWeb3jRx- Returns:
- a
Flowableinstance to emit pending transactions
-
blockFlowable
Description copied from interface:Web3jRxCreate anFlowableinstance that emits newly created blocks on the blockchain.- Specified by:
blockFlowablein interfaceWeb3jRx- Parameters:
fullTransactionObjects- if true, provides transactions embedded in blocks, otherwise transaction hashes- Returns:
- a
Flowableinstance that emits all new blocks as they are added to the blockchain
-
replayPastBlocksFlowable
public io.reactivex.Flowable<EthBlock> replayPastBlocksFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock, boolean fullTransactionObjects) Description copied from interface:Web3jRxCreate anFlowableinstance that emits all blocks from the blockchain contained within the requested range.- Specified by:
replayPastBlocksFlowablein interfaceWeb3jRx- Parameters:
startBlock- block number to commence withendBlock- block number to finish withfullTransactionObjects- if true, provides transactions embedded in blocks, otherwise transaction hashes- Returns:
- a
Flowableinstance to emit these blocks
-
replayPastBlocksFlowable
public io.reactivex.Flowable<EthBlock> replayPastBlocksFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock, boolean fullTransactionObjects, boolean ascending) Description copied from interface:Web3jRxCreate anFlowableinstance that emits all blocks from the blockchain contained within the requested range.- Specified by:
replayPastBlocksFlowablein interfaceWeb3jRx- Parameters:
startBlock- block number to commence withendBlock- block number to finish withfullTransactionObjects- if true, provides transactions embedded in blocks, otherwise transaction hashesascending- if true, emits blocks in ascending order between range, otherwise in descending order- Returns:
- a
Flowableinstance to emit these blocks
-
replayPastBlocksFlowable
public io.reactivex.Flowable<EthBlock> replayPastBlocksFlowable(DefaultBlockParameter startBlock, boolean fullTransactionObjects, io.reactivex.Flowable<EthBlock> onCompleteFlowable) Description copied from interface:Web3jRxCreate aFlowableinstance that emits all transactions from the blockchain starting with a provided block number. Once it has replayed up to the most current block, the provided Flowable is invoked.To automatically subscribe to new blocks, use
Web3jRx.replayPastAndFutureBlocksFlowable(DefaultBlockParameter, boolean).- Specified by:
replayPastBlocksFlowablein interfaceWeb3jRx- Parameters:
startBlock- the block number we wish to request fromfullTransactionObjects- if we require fullTransactionobjects to be provided in theEthBlockresponsesonCompleteFlowable- a subsequent Flowable that we wish to run once we are caught up with the latest block- Returns:
- a
Flowableinstance to emit all requested blocks
-
replayPastBlocksFlowable
public io.reactivex.Flowable<EthBlock> replayPastBlocksFlowable(DefaultBlockParameter startBlock, boolean fullTransactionObjects) Description copied from interface:Web3jRxCreates aFlowableinstance that emits all blocks from the requested block number to the most current. Once it has emitted the most current block, onComplete is called.- Specified by:
replayPastBlocksFlowablein interfaceWeb3jRx- Parameters:
startBlock- the block number we wish to request fromfullTransactionObjects- if we require fullTransactionobjects to be provided in theEthBlockresponses- Returns:
- a
Flowableinstance to emit all requested blocks
-
replayPastTransactionsFlowable
public io.reactivex.Flowable<Transaction> replayPastTransactionsFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) Description copied from interface:Web3jRxCreate aFlowableinstance that emits all transactions from the blockchain contained within the requested range.- Specified by:
replayPastTransactionsFlowablein interfaceWeb3jRx- Parameters:
startBlock- block number to commence withendBlock- block number to finish with- Returns:
- a
Flowableinstance to emit these transactions in the order they appear in the blocks
-
replayPastTransactionsFlowable
public io.reactivex.Flowable<Transaction> replayPastTransactionsFlowable(DefaultBlockParameter startBlock) Description copied from interface:Web3jRxCreates aFlowableinstance that emits all transactions from the requested block number to the most current. Once it has emitted the most current block's transactions, onComplete is called.- Specified by:
replayPastTransactionsFlowablein interfaceWeb3jRx- Parameters:
startBlock- the block number we wish to request from- Returns:
- a
Flowableinstance to emit all requested transactions
-
replayPastAndFutureBlocksFlowable
public io.reactivex.Flowable<EthBlock> replayPastAndFutureBlocksFlowable(DefaultBlockParameter startBlock, boolean fullTransactionObjects) Description copied from interface:Web3jRxCreates aFlowableinstance that emits all blocks from the requested block number to the most current. Once it has emitted the most current block, it starts emitting new blocks as they are created.- Specified by:
replayPastAndFutureBlocksFlowablein interfaceWeb3jRx- Parameters:
startBlock- the block number we wish to request fromfullTransactionObjects- if we require fullTransactionobjects to be provided in theEthBlockresponses- Returns:
- a
Flowableinstance to emit all requested blocks and future
-
replayPastAndFutureTransactionsFlowable
public io.reactivex.Flowable<Transaction> replayPastAndFutureTransactionsFlowable(DefaultBlockParameter startBlock) Description copied from interface:Web3jRxAs perWeb3jRx.replayPastAndFutureBlocksFlowable(DefaultBlockParameter, boolean), except that all transactions contained within the blocks are emitted.- Specified by:
replayPastAndFutureTransactionsFlowablein interfaceWeb3jRx- Parameters:
startBlock- the block number we wish to request from- Returns:
- a
Flowableinstance to emit all requested transactions and future
-
shutdown
public void shutdown()Description copied from interface:Web3jShutdowns a Web3j instance and closes opened resources. -
newBatch
Description copied from interface:BatcherCreate a newBatchRequest.
-