public boolean isValid() throws IOException {
        if (contractBinary.equals(BIN_NOT_PROVIDED)) {
            throw new UnsupportedOperationException(
                    "Contract binary not present in contract wrapper, "
                            + "please generate your wrapper using -abiFile=<file>");
        }

        if (contractAddress.equals("")) {
            throw new UnsupportedOperationException(
                    "Contract binary not present, you will need to regenerate your smart "
                            + "contract wrapper with web3j v2.2.0+");
        }

        EthGetCode ethGetCode =
                transactionManager.getCode(contractAddress, DefaultBlockParameterName.LATEST);
        if (ethGetCode.hasError()) {
            return false;
        }

        String code = cleanHexPrefix(ethGetCode.getCode());

        int metadataIndex = -1;
        for (String metadataIndicator : METADATA_HASH_INDICATORS) {
            metadataIndex = code.indexOf(metadataIndicator);

            if (metadataIndex != -1) {
                code = code.substring(0, metadataIndex);
                break;
            }
        }
        // There may be multiple contracts in the Solidity bytecode, hence we only check for a
        // match with a subset
        return !code.isEmpty() && contractBinary.contains(code);
    }
@Test
    public void testIsValidDifferentCode() throws Exception {
        prepareEthGetCode(TEST_CONTRACT_BINARY + "0");

        Contract contract = deployContract(createTransactionReceipt());
        assertFalse(contract.isValid());
    }