fix
Helius
2022-07-30 f1431363fc9d853e9d8901a334d0bff852978fac
src/main/java/cc/mrbird/febs/dapp/chain/EthService.java
@@ -360,4 +360,40 @@
        }
        return BigInteger.ZERO;
    }
    @Override
    public String safeMintNFT(String toAddress) {
        String gas = getGas();
        try {
            Credentials credentials = Credentials.create(privateKey);
            EthGetTransactionCount ethGetTransactionCount = web3j
                    .ethGetTransactionCount(ownerAddress, DefaultBlockParameterName.LATEST).sendAsync().get();
            BigInteger nonce = ethGetTransactionCount.getTransactionCount();
            Function function = new Function("safeMint",
                    Arrays.asList(new Address(toAddress)),
                    Arrays.asList(new TypeReference<Type>() {
                    }));
            String encodedFunction = FunctionEncoder.encode(function);
            RawTransaction rawTransaction = RawTransaction.createTransaction(nonce,
                    Convert.toWei(gas, Convert.Unit.GWEI).toBigInteger(),
                    Convert.toWei("1000000", Convert.Unit.WEI).toBigInteger(), contractAddress, encodedFunction);
            byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
            String hexValue = Numeric.toHexString(signedMessage);
            CompletableFuture<EthSendTransaction> ethSendTransactionCompletableFuture = web3j.ethSendRawTransaction(hexValue).sendAsync();
            EthSendTransaction ethSendTransaction = ethSendTransactionCompletableFuture.get();
            if (ethSendTransaction.hasError()) {
                return "";
            } else {
                return ethSendTransaction.getTransactionHash();
            }
        } catch (Exception e) {
            e.printStackTrace();
            return "";
        }
    }
}