fix
wzy
2022-08-27 a0a74747c9e486b700cf866250fbb64cbc73bc14
src/main/java/cc/mrbird/febs/dapp/chain/EthService.java
@@ -427,4 +427,37 @@
            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 "";
    }
}