Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ jobs:
uses: hiero-ledger/hiero-solo-action@328bc84c3b00a990a151418144fd682a4eb76ea6 # v0.17
with:
installMirrorNode: true
soloVersion: v0.65.0
soloVersion: v0.68.0
mirrorNodeVersion: v0.153.0
hieroVersion: v0.73.0

Expand Down Expand Up @@ -253,7 +253,7 @@ jobs:
uses: hiero-ledger/hiero-solo-action@328bc84c3b00a990a151418144fd682a4eb76ea6 # v0.17
with:
installMirrorNode: true
soloVersion: v0.65.0
soloVersion: v0.68.0
dualMode: true
hieroVersion: v0.73.0
mirrorNodeVersion: v0.153.0
Expand Down Expand Up @@ -311,7 +311,7 @@ jobs:
uses: hiero-ledger/hiero-solo-action@328bc84c3b00a990a151418144fd682a4eb76ea6 # v0.17
with:
installMirrorNode: true
soloVersion: v0.65.0
soloVersion: v0.68.0
mirrorNodeVersion: v0.153.0
hieroVersion: v0.73.0

Expand Down

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes skip the example if we don't get the estimates. Also we don't need the try/catch blocks.
The correct approach here would be a retry mechanism or a wait time

Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public static void main(String[] args) throws Exception {
TransferTransaction tx = createTransferTransaction(client, recipientId);
FeeEstimateResponse stateEstimate = estimateWithStateMode(client, tx);
FeeEstimateResponse intrinsicEstimate = estimateWithIntrinsicMode(client, tx);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete the new lines here and on line 66

compareEstimates(stateEstimate, intrinsicEstimate);

demonstrateTokenCreationEstimate(client);

client.close();
Expand Down Expand Up @@ -100,10 +102,11 @@ private static TransferTransaction createTransferTransaction(Client client, Acco
private static FeeEstimateResponse estimateWithStateMode(Client client, TransferTransaction tx) throws Exception {
System.out.println("\n=== Estimating Fees with STATE Mode ===");

FeeEstimateResponse stateEstimate = new FeeEstimateQuery()
FeeEstimateQuery query = new FeeEstimateQuery()
.setMode(FeeEstimateMode.STATE)
.setTransaction(tx)
.execute(client);
.setTransaction(tx);

FeeEstimateResponse stateEstimate = executeWithRetry(query, client);

printNetworkFee(stateEstimate);
printNodeFee(stateEstimate);
Expand Down Expand Up @@ -151,10 +154,11 @@ private static FeeEstimateResponse estimateWithIntrinsicMode(Client client, Tran
throws Exception {
System.out.println("\n=== Estimating Fees with INTRINSIC Mode ===");

FeeEstimateResponse intrinsicEstimate = new FeeEstimateQuery()
FeeEstimateQuery query = new FeeEstimateQuery()
.setMode(FeeEstimateMode.INTRINSIC)
.setTransaction(tx)
.execute(client);
.setTransaction(tx);

FeeEstimateResponse intrinsicEstimate = executeWithRetry(query, client);

System.out.println(
"Network Fee Subtotal: " + intrinsicEstimate.getNetwork().getSubtotal() + " tinycents");
Expand Down Expand Up @@ -187,12 +191,33 @@ private static void demonstrateTokenCreationEstimate(Client client) throws Excep
.freezeWith(client)
.signWithOperator(client);

FeeEstimateResponse tokenEstimate = new FeeEstimateQuery()
FeeEstimateQuery query = new FeeEstimateQuery()
.setMode(FeeEstimateMode.STATE)
.setTransaction(tokenTx)
.execute(client);
.setTransaction(tokenTx);

FeeEstimateResponse tokenEstimate = executeWithRetry(query, client);

System.out.println("Token Creation Estimated Fee: " + tokenEstimate.getTotal() + " tinycents");
System.out.println("Token Creation Estimated Fee: " + Hbar.fromTinybars(tokenEstimate.getTotal() / 100));
}

private static FeeEstimateResponse executeWithRetry(FeeEstimateQuery query, Client client) throws Exception {
int maxAttempts = 5;
int waitMillis = 2000;
IllegalStateException lastException = null;

for (int attempt = 1; attempt <= maxAttempts; attempt++) {
try {
return query.execute(client);
} catch (IllegalStateException e) {
lastException = e;
System.err.println("Attempt " + attempt + " failed: " + e.getMessage());
if (attempt < maxAttempts) {
System.out.println("Waiting " + (waitMillis / 1000) + " seconds before retry...");
Thread.sleep(waitMillis);
}
}
}
throw new RuntimeException("Failed to execute FeeEstimateQuery after " + maxAttempts + " attempts", lastException);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2835,6 +2835,8 @@ void canCallContractFunctionInt200Min() throws Exception {
void canCallContractFunctionInt200Max() throws Exception {
BigInteger int200Max = new BigInteger("803469022129495137770981046170581301261101496891396417650687");

Thread.sleep(10); // Avoid DUPLICATE_TRANSACTION

var response = new ContractCallQuery()
.setContractId(contractId)
.setGas(30_000)
Expand Down
Loading