| | |
| | | return ""; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public String ownerOfNft(Integer index) { |
| | | try { |
| | | String methodName = "ownerOf"; |
| | | List<Type> inputParameters = new ArrayList<>(); |
| | | List<TypeReference<?>> outputParameters = new ArrayList<>(); |
| | | Uint256 uint256 = new Uint256(index); |
| | | inputParameters.add(uint256); |
| | | TypeReference<Address> typeReference = new TypeReference<Address>() { |
| | | }; |
| | | outputParameters.add(typeReference); |
| | | Function function = new Function(methodName, inputParameters, outputParameters); |
| | | String data = FunctionEncoder.encode(function); |
| | | Transaction transaction = Transaction.createEthCallTransaction(null, contractAddress, data); |
| | | |
| | | EthCall ethCall; |
| | | String address = ""; |
| | | try { |
| | | ethCall = web3j.ethCall(transaction, DefaultBlockParameterName.LATEST).send(); |
| | | List<Type> results = FunctionReturnDecoder.decode(ethCall.getValue(), function.getOutputParameters()); |
| | | address = (String) results.get(0).getValue(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return address; |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return ""; |
| | | } |
| | | } |