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
-
Constructor Summary
ConstructorDescriptionJsonRpc2_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 anFlowable
instance 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 aaFlowable
instance that emits notifications for logs included in new imported blocks.newBatch()
Create a newBatchRequest
.io.reactivex.Flowable<NewHeadsNotification>
Creates aFlowable
instance that emits a notification when a new header is appended to a chain, including chain reorganizations.io.reactivex.Flowable<Transaction>
Create anFlowable
instance 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 aFlowable
instance 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 aFlowable
instance 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 aFlowable
instance 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 anFlowable
instance 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 anFlowable
instance that emits all blocks from the blockchain contained within the requested range.io.reactivex.Flowable<Transaction>
replayPastTransactionsFlowable
(DefaultBlockParameter startBlock) Creates aFlowable
instance that emits all transactions from the requested block number to the most current.io.reactivex.Flowable<Transaction>
replayPastTransactionsFlowable
(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) Create aFlowable
instance 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) void
shutdown()
Shutdowns a Web3j instance and closes opened resources.io.reactivex.Flowable<Transaction>
Create anFlowable
instance 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:
web3ClientVersion
in interfaceEthereum
-
web3Sha3
-
netVersion
- Specified by:
netVersion
in interfaceEthereum
-
netListening
- Specified by:
netListening
in interfaceEthereum
-
netPeerCount
- Specified by:
netPeerCount
in interfaceEthereum
-
adminNodeInfo
- Specified by:
adminNodeInfo
in interfaceEthereum
-
adminPeers
- Specified by:
adminPeers
in interfaceEthereum
-
adminAddPeer
- Specified by:
adminAddPeer
in interfaceEthereum
-
adminRemovePeer
- Specified by:
adminRemovePeer
in interfaceEthereum
-
adminDataDir
- Specified by:
adminDataDir
in interfaceEthereum
-
ethProtocolVersion
- Specified by:
ethProtocolVersion
in interfaceEthereum
-
ethChainId
- Specified by:
ethChainId
in interfaceEthereum
-
ethCoinbase
- Specified by:
ethCoinbase
in interfaceEthereum
-
ethSyncing
- Specified by:
ethSyncing
in interfaceEthereum
-
ethMining
-
ethHashrate
- Specified by:
ethHashrate
in interfaceEthereum
-
ethGasPrice
- Specified by:
ethGasPrice
in interfaceEthereum
-
ethMaxPriorityFeePerGas
- Specified by:
ethMaxPriorityFeePerGas
in interfaceEthereum
-
ethBaseFee
- Specified by:
ethBaseFee
in interfaceEthereum
-
ethFeeHistory
public Request<?,EthFeeHistory> ethFeeHistory(int blockCount, DefaultBlockParameter newestBlock, List<Double> rewardPercentiles) - Specified by:
ethFeeHistory
in interfaceEthereum
-
ethAccounts
- Specified by:
ethAccounts
in interfaceEthereum
-
ethBlockNumber
- Specified by:
ethBlockNumber
in interfaceEthereum
-
ethGetBalance
public Request<?,EthGetBalance> ethGetBalance(String address, DefaultBlockParameter defaultBlockParameter) - Specified by:
ethGetBalance
in interfaceEthereum
-
ethGetStorageAt
public Request<?,EthGetStorageAt> ethGetStorageAt(String address, BigInteger position, DefaultBlockParameter defaultBlockParameter) - Specified by:
ethGetStorageAt
in interfaceEthereum
-
ethGetTransactionCount
public Request<?,EthGetTransactionCount> ethGetTransactionCount(String address, DefaultBlockParameter defaultBlockParameter) - Specified by:
ethGetTransactionCount
in interfaceEthereum
-
ethGetBlockTransactionCountByHash
public Request<?,EthGetBlockTransactionCountByHash> ethGetBlockTransactionCountByHash(String blockHash) - Specified by:
ethGetBlockTransactionCountByHash
in interfaceEthereum
-
ethGetBlockTransactionCountByNumber
public Request<?,EthGetBlockTransactionCountByNumber> ethGetBlockTransactionCountByNumber(DefaultBlockParameter defaultBlockParameter) - Specified by:
ethGetBlockTransactionCountByNumber
in interfaceEthereum
-
ethGetUncleCountByBlockHash
- Specified by:
ethGetUncleCountByBlockHash
in interfaceEthereum
-
ethGetUncleCountByBlockNumber
public Request<?,EthGetUncleCountByBlockNumber> ethGetUncleCountByBlockNumber(DefaultBlockParameter defaultBlockParameter) - Specified by:
ethGetUncleCountByBlockNumber
in interfaceEthereum
-
ethGetCode
public Request<?,EthGetCode> ethGetCode(String address, DefaultBlockParameter defaultBlockParameter) - Specified by:
ethGetCode
in interfaceEthereum
-
ethSign
-
ethSendTransaction
- Specified by:
ethSendTransaction
in interfaceEthereum
-
ethSendRawTransaction
- Specified by:
ethSendRawTransaction
in interfaceEthereum
-
ethCall
public Request<?,EthCall> ethCall(Transaction transaction, DefaultBlockParameter defaultBlockParameter) -
ethEstimateGas
- Specified by:
ethEstimateGas
in interfaceEthereum
-
ethGetBlockByHash
public Request<?,EthBlock> ethGetBlockByHash(String blockHash, boolean returnFullTransactionObjects) - Specified by:
ethGetBlockByHash
in interfaceEthereum
-
ethGetBlockByNumber
public Request<?,EthBlock> ethGetBlockByNumber(DefaultBlockParameter defaultBlockParameter, boolean returnFullTransactionObjects) - Specified by:
ethGetBlockByNumber
in interfaceEthereum
-
ethGetTransactionByHash
- Specified by:
ethGetTransactionByHash
in interfaceEthereum
-
ethGetTransactionByBlockHashAndIndex
public Request<?,EthTransaction> ethGetTransactionByBlockHashAndIndex(String blockHash, BigInteger transactionIndex) - Specified by:
ethGetTransactionByBlockHashAndIndex
in interfaceEthereum
-
ethGetTransactionByBlockNumberAndIndex
public Request<?,EthTransaction> ethGetTransactionByBlockNumberAndIndex(DefaultBlockParameter defaultBlockParameter, BigInteger transactionIndex) - Specified by:
ethGetTransactionByBlockNumberAndIndex
in interfaceEthereum
-
ethGetTransactionReceipt
- Specified by:
ethGetTransactionReceipt
in interfaceEthereum
-
ethGetBlockReceipts
public Request<?,EthGetBlockReceipts> ethGetBlockReceipts(DefaultBlockParameter defaultBlockParameter) - Specified by:
ethGetBlockReceipts
in interfaceEthereum
-
ethGetUncleByBlockHashAndIndex
public Request<?,EthBlock> ethGetUncleByBlockHashAndIndex(String blockHash, BigInteger transactionIndex) - Specified by:
ethGetUncleByBlockHashAndIndex
in interfaceEthereum
-
ethGetUncleByBlockNumberAndIndex
public Request<?,EthBlock> ethGetUncleByBlockNumberAndIndex(DefaultBlockParameter defaultBlockParameter, BigInteger uncleIndex) - Specified by:
ethGetUncleByBlockNumberAndIndex
in interfaceEthereum
-
ethGetCompilers
- Specified by:
ethGetCompilers
in interfaceEthereum
-
ethCompileLLL
- Specified by:
ethCompileLLL
in interfaceEthereum
-
ethCompileSolidity
- Specified by:
ethCompileSolidity
in interfaceEthereum
-
ethCompileSerpent
- Specified by:
ethCompileSerpent
in interfaceEthereum
-
ethNewFilter
- Specified by:
ethNewFilter
in interfaceEthereum
-
ethNewBlockFilter
- Specified by:
ethNewBlockFilter
in interfaceEthereum
-
ethNewPendingTransactionFilter
- Specified by:
ethNewPendingTransactionFilter
in interfaceEthereum
-
ethUninstallFilter
- Specified by:
ethUninstallFilter
in interfaceEthereum
-
ethGetFilterChanges
- Specified by:
ethGetFilterChanges
in interfaceEthereum
-
ethGetFilterLogs
- Specified by:
ethGetFilterLogs
in interfaceEthereum
-
ethGetLogs
- Specified by:
ethGetLogs
in interfaceEthereum
-
ethGetProof
public Request<?,EthGetProof> ethGetProof(String address, List<String> storageKeys, String quantity) - Specified by:
ethGetProof
in interfaceEthereum
-
ethGetWork
- Specified by:
ethGetWork
in interfaceEthereum
-
ethSubmitWork
- Specified by:
ethSubmitWork
in interfaceEthereum
-
ethSubmitHashrate
- Specified by:
ethSubmitHashrate
in interfaceEthereum
-
dbPutString
public Request<?,DbPutString> dbPutString(String databaseName, String keyName, String stringToStore) - Specified by:
dbPutString
in interfaceEthereum
-
dbGetString
- Specified by:
dbGetString
in interfaceEthereum
-
dbPutHex
-
dbGetHex
-
shhPost
-
shhVersion
- Specified by:
shhVersion
in interfaceEthereum
-
shhNewIdentity
- Specified by:
shhNewIdentity
in interfaceEthereum
-
shhHasIdentity
- Specified by:
shhHasIdentity
in interfaceEthereum
-
shhNewGroup
- Specified by:
shhNewGroup
in interfaceEthereum
-
shhAddToGroup
- Specified by:
shhAddToGroup
in interfaceEthereum
-
shhNewFilter
- Specified by:
shhNewFilter
in interfaceEthereum
-
shhUninstallFilter
- Specified by:
shhUninstallFilter
in interfaceEthereum
-
shhGetFilterChanges
- Specified by:
shhGetFilterChanges
in interfaceEthereum
-
shhGetMessages
- Specified by:
shhGetMessages
in interfaceEthereum
-
txPoolStatus
- Specified by:
txPoolStatus
in interfaceEthereum
-
newHeadsNotifications
Description copied from interface:Web3jRx
Creates aFlowable
instance that emits a notification when a new header is appended to a chain, including chain reorganizations.- Specified by:
newHeadsNotifications
in interfaceWeb3jRx
- Returns:
- a
Flowable
instance 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:Web3jRx
Creates aaFlowable
instance that emits notifications for logs included in new imported blocks.- Specified by:
logsNotifications
in 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
Flowable
instance that emits logs included in new blocks
-
ethBlockHashFlowable
Description copied from interface:Web3jRx
Create an Flowable to emit block hashes.- Specified by:
ethBlockHashFlowable
in interfaceWeb3jRx
- Returns:
- a
Flowable
instance that emits all new block hashes as new blocks are created on the blockchain
-
ethPendingTransactionHashFlowable
Description copied from interface:Web3jRx
Create 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:
ethPendingTransactionHashFlowable
in interfaceWeb3jRx
- Returns:
- a
Flowable
instance to emit pending transaction hashes.
-
ethLogFlowable
Description copied from interface:Web3jRx
Create an flowable to filter for specific log events on the blockchain.- Specified by:
ethLogFlowable
in interfaceWeb3jRx
- Parameters:
ethFilter
- filter criteria- Returns:
- a
Flowable
instance that emits all Log events matching the filter
-
transactionFlowable
Description copied from interface:Web3jRx
Create anFlowable
instance 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:
transactionFlowable
in interfaceWeb3jRx
- Returns:
- a
Flowable
instance to emit new transactions on the blockchain
-
pendingTransactionFlowable
Description copied from interface:Web3jRx
Create anFlowable
instance to emit all pending transactions that have yet to be placed into a block on the blockchain.- Specified by:
pendingTransactionFlowable
in interfaceWeb3jRx
- Returns:
- a
Flowable
instance to emit pending transactions
-
blockFlowable
Description copied from interface:Web3jRx
Create anFlowable
instance that emits newly created blocks on the blockchain.- Specified by:
blockFlowable
in interfaceWeb3jRx
- Parameters:
fullTransactionObjects
- if true, provides transactions embedded in blocks, otherwise transaction hashes- Returns:
- a
Flowable
instance 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:Web3jRx
Create anFlowable
instance that emits all blocks from the blockchain contained within the requested range.- Specified by:
replayPastBlocksFlowable
in 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
Flowable
instance to emit these blocks
-
replayPastBlocksFlowable
public io.reactivex.Flowable<EthBlock> replayPastBlocksFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock, boolean fullTransactionObjects, boolean ascending) Description copied from interface:Web3jRx
Create anFlowable
instance that emits all blocks from the blockchain contained within the requested range.- Specified by:
replayPastBlocksFlowable
in 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
Flowable
instance to emit these blocks
-
replayPastBlocksFlowable
public io.reactivex.Flowable<EthBlock> replayPastBlocksFlowable(DefaultBlockParameter startBlock, boolean fullTransactionObjects, io.reactivex.Flowable<EthBlock> onCompleteFlowable) Description copied from interface:Web3jRx
Create aFlowable
instance 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:
replayPastBlocksFlowable
in interfaceWeb3jRx
- Parameters:
startBlock
- the block number we wish to request fromfullTransactionObjects
- if we require fullTransaction
objects to be provided in theEthBlock
responsesonCompleteFlowable
- a subsequent Flowable that we wish to run once we are caught up with the latest block- Returns:
- a
Flowable
instance to emit all requested blocks
-
replayPastBlocksFlowable
public io.reactivex.Flowable<EthBlock> replayPastBlocksFlowable(DefaultBlockParameter startBlock, boolean fullTransactionObjects) Description copied from interface:Web3jRx
Creates aFlowable
instance 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:
replayPastBlocksFlowable
in interfaceWeb3jRx
- Parameters:
startBlock
- the block number we wish to request fromfullTransactionObjects
- if we require fullTransaction
objects to be provided in theEthBlock
responses- Returns:
- a
Flowable
instance to emit all requested blocks
-
replayPastTransactionsFlowable
public io.reactivex.Flowable<Transaction> replayPastTransactionsFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) Description copied from interface:Web3jRx
Create aFlowable
instance that emits all transactions from the blockchain contained within the requested range.- Specified by:
replayPastTransactionsFlowable
in interfaceWeb3jRx
- Parameters:
startBlock
- block number to commence withendBlock
- block number to finish with- Returns:
- a
Flowable
instance 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:Web3jRx
Creates aFlowable
instance 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:
replayPastTransactionsFlowable
in interfaceWeb3jRx
- Parameters:
startBlock
- the block number we wish to request from- Returns:
- a
Flowable
instance to emit all requested transactions
-
replayPastAndFutureBlocksFlowable
public io.reactivex.Flowable<EthBlock> replayPastAndFutureBlocksFlowable(DefaultBlockParameter startBlock, boolean fullTransactionObjects) Description copied from interface:Web3jRx
Creates aFlowable
instance 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:
replayPastAndFutureBlocksFlowable
in interfaceWeb3jRx
- Parameters:
startBlock
- the block number we wish to request fromfullTransactionObjects
- if we require fullTransaction
objects to be provided in theEthBlock
responses- Returns:
- a
Flowable
instance to emit all requested blocks and future
-
replayPastAndFutureTransactionsFlowable
public io.reactivex.Flowable<Transaction> replayPastAndFutureTransactionsFlowable(DefaultBlockParameter startBlock) Description copied from interface:Web3jRx
As perWeb3jRx.replayPastAndFutureBlocksFlowable(DefaultBlockParameter, boolean)
, except that all transactions contained within the blocks are emitted.- Specified by:
replayPastAndFutureTransactionsFlowable
in interfaceWeb3jRx
- Parameters:
startBlock
- the block number we wish to request from- Returns:
- a
Flowable
instance to emit all requested transactions and future
-
shutdown
public void shutdown()Description copied from interface:Web3j
Shutdowns a Web3j instance and closes opened resources. -
newBatch
Description copied from interface:Batcher
Create a newBatchRequest
.
-