org.web3j.protocol.core.Request.send()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(198)

本文整理了Java中org.web3j.protocol.core.Request.send方法的一些代码示例,展示了Request.send的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.send方法的具体详情如下:
包路径:org.web3j.protocol.core.Request
类名称:Request
方法名:send

Request.send介绍

暂无

代码示例

代码示例来源:origin: web3j/web3j

  1. private BigInteger getBlockNumber(
  2. DefaultBlockParameter defaultBlockParameter) throws IOException {
  3. if (defaultBlockParameter instanceof DefaultBlockParameterNumber) {
  4. return ((DefaultBlockParameterNumber) defaultBlockParameter).getBlockNumber();
  5. } else {
  6. EthBlock latestEthBlock = web3j.ethGetBlockByNumber(
  7. defaultBlockParameter, false).send();
  8. return latestEthBlock.getBlock().getNumber();
  9. }
  10. }

代码示例来源:origin: web3j/web3j

  1. @Test
  2. public void testEthCall() throws Exception {
  3. EthCall ethCall = web3j.ethCall(config.buildTransaction(),
  4. DefaultBlockParameter.valueOf("latest")).send();
  5. assertThat(DefaultBlockParameterName.LATEST.getValue(), is("latest"));
  6. assertThat(ethCall.getValue(), is("0x"));
  7. }

代码示例来源:origin: web3j/web3j

  1. @Test
  2. public void testNetVersion() throws Exception {
  3. web3j.netVersion().send();
  4. verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"net_version\",\"params\":[],\"id\":1}");
  5. }

代码示例来源:origin: web3j/web3j

  1. @Test
  2. public void testEthCoinbase() throws Exception {
  3. web3j.ethCoinbase().send();
  4. verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_coinbase\",\"params\":[],\"id\":1}");
  5. }

代码示例来源:origin: web3j/web3j

  1. @Test
  2. public void testEthGetTransactionCount() throws Exception {
  3. web3j.ethGetTransactionCount("0x407d73d8a49eeb85d32cf465507dd71d507100c1",
  4. DefaultBlockParameterName.LATEST).send();
  5. verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getTransactionCount\","
  6. + "\"params\":[\"0x407d73d8a49eeb85d32cf465507dd71d507100c1\",\"latest\"],"
  7. + "\"id\":1}");
  8. }

代码示例来源:origin: web3j/web3j

  1. @Test
  2. public void testEthGetBlockTransactionCountByHash() throws Exception {
  3. web3j.ethGetBlockTransactionCountByHash(
  4. "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238").send();
  5. //CHECKSTYLE:OFF
  6. verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockTransactionCountByHash\",\"params\":[\"0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238\"],\"id\":1}");
  7. //CHECKSTYLE:ON
  8. }

代码示例来源:origin: web3j/web3j

  1. @Test
  2. public void testEthGetUncleCountByBlockHash() throws Exception {
  3. web3j.ethGetUncleCountByBlockHash(
  4. "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238").send();
  5. //CHECKSTYLE:OFF
  6. verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getUncleCountByBlockHash\",\"params\":[\"0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238\"],\"id\":1}");
  7. //CHECKSTYLE:ON
  8. }

代码示例来源:origin: web3j/web3j

  1. @Test
  2. public void testEthNewPendingTransactionFilter() throws Exception {
  3. web3j.ethNewPendingTransactionFilter().send();
  4. verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_newPendingTransactionFilter\","
  5. + "\"params\":[],\"id\":1}");
  6. }

代码示例来源:origin: web3j/web3j

  1. @Test
  2. public void testShhAddToGroup() throws Exception {
  3. //CHECKSTYLE:OFF
  4. web3j.shhAddToGroup("0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1").send();
  5. verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"shh_addToGroup\",\"params\":[\"0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1\"],\"id\":1}");
  6. //CHECKSTYLE:ON
  7. }

代码示例来源:origin: web3j/web3j

  1. @Test
  2. public void testEthGetUncleCountByBlockHash() throws Exception {
  3. EthGetUncleCountByBlockHash ethGetUncleCountByBlockHash =
  4. web3j.ethGetUncleCountByBlockHash(config.validBlockHash()).send();
  5. assertThat(ethGetUncleCountByBlockHash.getUncleCount(),
  6. equalTo(config.validBlockUncleCount()));
  7. }

代码示例来源:origin: web3j/web3j

  1. @Test
  2. public void testEthGetUncleCountByBlockNumber() throws Exception {
  3. EthGetUncleCountByBlockNumber ethGetUncleCountByBlockNumber =
  4. web3j.ethGetUncleCountByBlockNumber(
  5. DefaultBlockParameter.valueOf("latest")).send();
  6. assertThat(ethGetUncleCountByBlockNumber.getUncleCount(),
  7. equalTo(config.validBlockUncleCount()));
  8. }

代码示例来源:origin: web3j/web3j

  1. @Test
  2. public void testEthGetTransactionByBlockHashAndIndex() throws Exception {
  3. BigInteger index = BigInteger.ONE;
  4. EthTransaction ethTransaction = web3j.ethGetTransactionByBlockHashAndIndex(
  5. config.validBlockHash(), index).send();
  6. assertTrue(ethTransaction.getTransaction().isPresent());
  7. Transaction transaction = ethTransaction.getTransaction().get();
  8. assertThat(transaction.getBlockHash(), is(config.validBlockHash()));
  9. assertThat(transaction.getTransactionIndex(), equalTo(index));
  10. }

代码示例来源:origin: web3j/web3j

  1. @Test
  2. public void testEthGetBlockByHashReturnFullTransactionObjects() throws Exception {
  3. EthBlock ethBlock = web3j.ethGetBlockByHash(config.validBlockHash(), true)
  4. .send();
  5. EthBlock.Block block = ethBlock.getBlock();
  6. assertNotNull(ethBlock.getBlock());
  7. assertThat(block.getNumber(), equalTo(config.validBlock()));
  8. assertThat(block.getTransactions().size(),
  9. equalTo(config.validBlockTransactionCount().intValue()));
  10. }

代码示例来源:origin: web3j/web3j

  1. @Test
  2. public void testEthGetBlockTransactionCountByNumber() throws Exception {
  3. EthGetBlockTransactionCountByNumber ethGetBlockTransactionCountByNumber =
  4. web3j.ethGetBlockTransactionCountByNumber(
  5. DefaultBlockParameter.valueOf(config.validBlock())).send();
  6. assertThat(ethGetBlockTransactionCountByNumber.getTransactionCount(),
  7. equalTo(config.validBlockTransactionCount()));
  8. }

代码示例来源:origin: web3j/web3j

  1. private List<EthLog.LogResult> createFilterForEvent(
  2. String encodedEventSignature, String contractAddress) throws Exception {
  3. EthFilter ethFilter = new EthFilter(
  4. DefaultBlockParameterName.EARLIEST,
  5. DefaultBlockParameterName.LATEST,
  6. contractAddress
  7. );
  8. ethFilter.addSingleTopic(encodedEventSignature);
  9. EthLog ethLog = web3j.ethGetLogs(ethFilter).send();
  10. return ethLog.getLogs();
  11. }
  12. }

代码示例来源:origin: web3j/web3j

  1. @Test
  2. public void testPersonalListAccounts() throws Exception {
  3. PersonalListAccounts personalListAccounts = parity.personalListAccounts().send();
  4. assertNotNull(personalListAccounts.getAccountIds());
  5. }

代码示例来源:origin: web3j/web3j

  1. @Test
  2. public void testEthSyncing() throws Exception {
  3. EthSyncing ethSyncing = web3j.ethSyncing().send();
  4. assertNotNull(ethSyncing.getResult());
  5. }

代码示例来源:origin: web3j/web3j

  1. @Test
  2. public void testEthGetUncleByBlockHashAndIndex() throws Exception {
  3. EthBlock ethBlock = web3j.ethGetUncleByBlockHashAndIndex(
  4. config.validUncleBlockHash(), BigInteger.ZERO).send();
  5. assertNotNull(ethBlock.getBlock());
  6. }

代码示例来源:origin: web3j/web3j

  1. @Ignore // The method shh_version does not exist/is not available
  2. @Test
  3. public void testShhVersion() throws Exception {
  4. ShhVersion shhVersion = web3j.shhVersion().send();
  5. assertNotNull(shhVersion.getVersion());
  6. }

代码示例来源:origin: web3j/web3j

  1. @Test
  2. public void testEthGetUncleByBlockNumberAndIndex() throws Exception {
  3. EthBlock ethBlock = web3j.ethGetUncleByBlockNumberAndIndex(
  4. DefaultBlockParameter.valueOf(config.validUncleBlock()), BigInteger.ZERO)
  5. .send();
  6. assertNotNull(ethBlock.getBlock());
  7. }

相关文章