Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An efficient way to calculate the cost of non-free-queries #2460

Open
quiet-node opened this issue Aug 19, 2024 · 1 comment
Open

An efficient way to calculate the cost of non-free-queries #2460

quiet-node opened this issue Aug 19, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@quiet-node
Copy link
Member

quiet-node commented Aug 19, 2024

Problem

I've noticed that some queries (e.g., TransactionRecordQuery) charge the operator account a fee. For example, on localnet, after executing the following query:

const transactionRecord = await new TransactionRecordQuery()
    .setTransactionId(transactionId)
    .setValidateReceiptStatus(false)
    .execute(clientMain);

by comparing the balance of the operator account before and after execution, there's a difference of 83,997 tinybars.

Is there an efficient way to determine this fee without comparing the operator's balance before and after execution?? Currently, I'm comparing the account balance before and after the query execution to determine the charged amount. To do this, I have to wait 200ms for each balance query for the balances to properly updated to get the accurate balance—totaling 400ms for one request (before and after). Depending on the size of the callData, a single client call (eth_sendRawTransaction) can involve multiple requests (10+ or even 20+), which significantly increases the total wait time just to calculate the balance difference. I'm hoping there's a better and more performance-oriented method to figure out this cost

I've tried the <query>.getCost() method, but it always returns 9 tinybars, and I'm not sure what that amount is for.

Solution

Add an API in the query class to expose this charged fee natively.

Alternatives

No response

@ivaylonikolov7
Copy link
Contributor

Hey @quiet-node,

I think this feature you offer would be a good addition. We did some research and we think this would not be handled on SDK level but we are considering other options that can solve your issue. Will keep you updated on any news that can help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants