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());
    }


阅读更多
想对作者说点什么?

博主推荐

换一批

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