web3j GasUsed GasPrice Transaction Input 交易是否成功

//        EthGetTransactionReceipt send = Web3JClient.getWeb3j().ethGetTransactionReceipt(txhash).send();
//        EthTransaction send1 = Web3JClient.getWeb3j().ethGetTransactionByHash(txhash).send();
//        BigInteger transactionReceipt = send1.getTransaction().get().getGasPrice();
//        BigInteger gasUsed = send.getTransactionReceipt().get().getGasUsed();
 public void parseInput(){
        String inputData = "0xa9059cbb0000000000000000000000006a2972e43f38f0b8217c119394d9b5a4cd116e9c000000000000000000000000000000000000000000000001bc16d674ec800000";
        String method = inputData.substring(0,10);
        String to = inputData.substring(10,74);
        String value = inputData.substring(74);
        Method refMethod = null;
        try {
            refMethod = TypeDecoder.class.getDeclaredMethod("decode",String.class,int.class,Class.class);
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
        refMethod.setAccessible(true);
        Address address = null;
        try {
            address = (Address)refMethod.invoke(null,to,0,Address.class);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        Uint256 amount = null;
        try {
            amount = (Uint256) refMethod.invoke(null,value,0,Uint256.class);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        System.out.println("method="+method+"\nto="+to+"\nvalue="+value+"\naddress="+address.getValue()+"\namount="+amount.getValue());
    }
   /**
     *
     * @param web3j
     * @param txhash
     * @return
     * 0失败 1成功
     */
    public static String getStatus(Web3j web3j,String txhash){
        String status = "0";
        try {
            EthGetTransactionReceipt ethGetTransactionReceipt = web3j.ethGetTransactionReceipt(txhash).sendAsync().get();
            String status1 = ethGetTransactionReceipt.getTransactionReceipt().get().getStatus();
            if(!Strings.isNullOrEmpty(status1)){
                status = status1.substring(2);
                System.out.println(status);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
        return status;
    }


 

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试

关闭