Я не знаю, задавался ли вопрос раньше, но я не нашел ни одного.Я сталкиваюсь с этой проблемой со вчерашнего дня.Я могу получить баланс и txnHash, но он никогда не показывает на etherScan.io и не дает мне txn.чек.Ниже приведен мой код (хотя, я думаю, я уже перепробовал практически все возможные материалы).
ContractGasProvider gasPriceProvider = new DefaultGasProvider();
TransactionManager txManager = new RawTransactionManager(
web3, credentials, ChainId.MAINNET,transactionReceiptProcessor);
int sleepDuration = 15 * 1000;
int attempts = 8;
TransactionManager transactionManager = new ClientTransactionManager(web3, credentials.getAddress(), attempts, sleepDuration);
ERC20 contract = ERC20.load(CONTRACT_ADDRESS, web3, transactionManager, gasPriceProvider);
balance = contract.balanceOf(credentials.getAddress()).send();
Теперь я могу получить одноразовое значение с кодом ниже
credentials.getAddress(), DefaultBlockParameterName.LATEST).sendAsync().get();
Log.e("old nonce","--old once--"+ethGetTransactionCount.getTransactionCount());
BigInteger nonce = ethGetTransactionCount.getTransactionCount().add(BigInteger.valueOf(1));
Ниже приведен код для запуска транзакции, и я получаю txnHash
GAS_PRICE = BigInteger.valueOf(15);
GAS_LIMIT = BigInteger.valueOf(90000);
RawTransaction rawTransaction = RawTransaction.createEtherTransaction(nonce, GAS_PRICE, GAS_LIMIT, TO_ADDRESS, CUSTOM_AMOUNT);
// Note that <gas price>, <gas limit>, <toAddress> will have been provided by the API in step 1.
// sign & send our transaction
byte[] signedMessage = TransactionEncoder.signMessage(rawTransaction, credentials);
String hexValue = Numeric.toHexString(signedMessage);
Log.e("hexValue is--", hexValue);
EthSendTransaction ethSendTransaction = web3.ethSendRawTransaction( hexValue).sendAsync().get();
transactionHash = ethSendTransaction.getTransactionHash();
Теперь яЯ использую код ниже, чтобы получить квитанцию, но она всегда выдает ошибку отсутствия квитанции для этого txnHash
Optional<TransactionReceipt> receiptOptional =
sendTransactionReceiptRequest(transactionHash, web3);
long millis = 10000;
int attempts = 4;
for (int i = 0; i < attempts; i++) {
if (!receiptOptional.isPresent()) {
Thread.sleep(millis);
receiptOptional = sendTransactionReceiptRequest(transactionHash, web3);
} else {
String contractAddress = receiptOptional.get().getContractAddress();
Log.e("contractAddress is--", contractAddress);
return null;
}
}
throw new TransactionException("Transaction receipt was not generated after " + (millis * attempts / 1000)
+ " seconds for transaction: " + transactionHash);