org.web3j.utils.Numeric.toBigInt()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(138)

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

Numeric.toBigInt介绍

暂无

代码示例

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

  1. public static BigInteger toBigInt(byte[] value, int offset, int length) {
  2. return toBigInt((Arrays.copyOfRange(value, offset, offset + length)));
  3. }

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

  1. public static ECKeyPair deserialize(byte[] input) {
  2. if (input.length != PRIVATE_KEY_SIZE + PUBLIC_KEY_SIZE) {
  3. throw new RuntimeException("Invalid input key size");
  4. }
  5. BigInteger privateKey = Numeric.toBigInt(input, 0, PRIVATE_KEY_SIZE);
  6. BigInteger publicKey = Numeric.toBigInt(input, PRIVATE_KEY_SIZE, PUBLIC_KEY_SIZE);
  7. return new ECKeyPair(privateKey, publicKey);
  8. }
  9. }

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

  1. public void setV(Object v) {
  2. if (v instanceof String) {
  3. this.v = Numeric.toBigInt((String) v).longValueExact();
  4. } else if (v instanceof Integer) {
  5. this.v = ((Integer) v).longValue();
  6. } else {
  7. this.v = (Long) v;
  8. }
  9. }

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

  1. static Bool decodeBool(String rawInput, int offset) {
  2. String input = rawInput.substring(offset, offset + MAX_BYTE_LENGTH_FOR_HEX_STRING);
  3. BigInteger numericValue = Numeric.toBigInt(input);
  4. boolean value = numericValue.equals(BigInteger.ONE);
  5. return new Bool(value);
  6. }

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

  1. public static Bip32ECKeyPair create(byte[] privateKey, byte[] chainCode) {
  2. return create(Numeric.toBigInt(privateKey), chainCode);
  3. }

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

  1. @Test
  2. public void testShhPost() throws Exception {
  3. //CHECKSTYLE:OFF
  4. web3j.shhPost(new ShhPost(
  5. "0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1",
  6. "0x3e245533f97284d442460f2998cd41858798ddf04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a0d4d661997d3940272b717b1",
  7. Arrays.asList("0x776869737065722d636861742d636c69656e74", "0x4d5a695276454c39425154466b61693532"),
  8. "0x7b2274797065223a226d6",
  9. Numeric.toBigInt("0x64"),
  10. Numeric.toBigInt("0x64"))).send();
  11. verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"shh_post\",\"params\":[{\"from\":\"0x04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a03e245533f97284d442460f2998cd41858798ddfd4d661997d3940272b717b1\",\"to\":\"0x3e245533f97284d442460f2998cd41858798ddf04f96a5e25610293e42a73908e93ccc8c4d4dc0edcfa9fa872f50cb214e08ebf61a0d4d661997d3940272b717b1\",\"topics\":[\"0x776869737065722d636861742d636c69656e74\",\"0x4d5a695276454c39425154466b61693532\"],\"payload\":\"0x7b2274797065223a226d6\",\"priority\":\"0x64\",\"ttl\":\"0x64\"}],\"id\":1}");
  12. //CHECKSTYLE:ON
  13. }

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

  1. private void assertCorrectEntropy(String expected, String mnemonic, int size) {
  2. Assert.assertEquals(expected, Numeric.toHexStringNoPrefixZeroPadded(
  3. Numeric.toBigInt(MnemonicUtils.generateEntropy(mnemonic)), size));
  4. }
  5. }

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

  1. @Test
  2. public void testEthUninstallFilter() throws Exception {
  3. web3j.ethUninstallFilter(Numeric.toBigInt("0xb")).send();
  4. verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_uninstallFilter\","
  5. + "\"params\":[\"0x0b\"],\"id\":1}");
  6. }

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

  1. @Test
  2. public void testEthGetFilterChanges() throws Exception {
  3. web3j.ethGetFilterChanges(Numeric.toBigInt("0x16")).send();
  4. verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getFilterChanges\","
  5. + "\"params\":[\"0x16\"],\"id\":1}");
  6. }

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

  1. @Test
  2. public void testEthGetFilterLogs() throws Exception {
  3. web3j.ethGetFilterLogs(Numeric.toBigInt("0x16")).send();
  4. verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getFilterLogs\","
  5. + "\"params\":[\"0x16\"],\"id\":1}");
  6. }

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

  1. @Test
  2. public void testShhGetFilterChanges() throws Exception {
  3. web3j.shhGetFilterChanges(Numeric.toBigInt("0x7")).send();
  4. verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"shh_getFilterChanges\","
  5. + "\"params\":[\"0x07\"],\"id\":1}");
  6. }

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

  1. @Test
  2. public void testShhUninstallFilter() throws Exception {
  3. web3j.shhUninstallFilter(Numeric.toBigInt("0x7")).send();
  4. verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"shh_uninstallFilter\","
  5. + "\"params\":[\"0x07\"],\"id\":1}");
  6. }

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

  1. @Test
  2. public void testShhGetMessages() throws Exception {
  3. web3j.shhGetMessages(Numeric.toBigInt("0x7")).send();
  4. verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"shh_getMessages\","
  5. + "\"params\":[\"0x07\"],\"id\":1}");
  6. }
  7. }

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

  1. @Test
  2. public void testEthGetCode() throws Exception {
  3. web3j.ethGetCode("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b",
  4. DefaultBlockParameter.valueOf(Numeric.toBigInt("0x2"))).send();
  5. verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getCode\","
  6. + "\"params\":[\"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\",\"0x2\"],\"id\":1}");
  7. }

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

  1. @Test
  2. public void testEthGetTransactionByBlockNumberAndIndex() throws Exception {
  3. web3j.ethGetTransactionByBlockNumberAndIndex(
  4. DefaultBlockParameter.valueOf(Numeric.toBigInt("0x29c")), BigInteger.ZERO).send();
  5. verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getTransactionByBlockNumberAndIndex\","
  6. + "\"params\":[\"0x29c\",\"0x0\"],\"id\":1}");
  7. }

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

  1. @Test
  2. public void testEthGetBlockTransactionCountByNumber() throws Exception {
  3. web3j.ethGetBlockTransactionCountByNumber(
  4. DefaultBlockParameter.valueOf(Numeric.toBigInt("0xe8"))).send();
  5. verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockTransactionCountByNumber\","
  6. + "\"params\":[\"0xe8\"],\"id\":1}");
  7. }

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

  1. @Test
  2. public void testEthGetUncleCountByBlockNumber() throws Exception {
  3. web3j.ethGetUncleCountByBlockNumber(
  4. DefaultBlockParameter.valueOf(Numeric.toBigInt("0xe8"))).send();
  5. verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getUncleCountByBlockNumber\","
  6. + "\"params\":[\"0xe8\"],\"id\":1}");
  7. }

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

  1. @Test
  2. public void testEthGetBlockByNumber() throws Exception {
  3. web3j.ethGetBlockByNumber(
  4. DefaultBlockParameter.valueOf(Numeric.toBigInt("0x1b4")), true).send();
  5. verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByNumber\","
  6. + "\"params\":[\"0x1b4\",true],\"id\":1}");
  7. }

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

  1. @Test
  2. public void testEthGetUncleByBlockNumberAndIndex() throws Exception {
  3. web3j.ethGetUncleByBlockNumberAndIndex(
  4. DefaultBlockParameter.valueOf(Numeric.toBigInt("0x29c")), BigInteger.ZERO).send();
  5. verifyResult("{\"jsonrpc\":\"2.0\",\"method\":\"eth_getUncleByBlockNumberAndIndex\","
  6. + "\"params\":[\"0x29c\",\"0x0\"],\"id\":1}");
  7. }

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

  1. @Test
  2. public void testEthGetLogsWithNumericBlockRange() throws Exception {
  3. web3j.ethGetLogs(new EthFilter(
  4. DefaultBlockParameter.valueOf(Numeric.toBigInt("0xe8")),
  5. DefaultBlockParameter.valueOf("latest"), ""))
  6. .send();
  7. verifyResult(
  8. "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getLogs\","
  9. + "\"params\":[{\"topics\":[],\"fromBlock\":\"0xe8\","
  10. + "\"toBlock\":\"latest\",\"address\":[\"\"]}],\"id\":1}");
  11. }

相关文章