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

Introduce the autoCost helper for transaction requests #3535

Closed
danielbate opened this issue Jan 3, 2025 · 0 comments · Fixed by #3539
Closed

Introduce the autoCost helper for transaction requests #3535

danielbate opened this issue Jan 3, 2025 · 0 comments · Fixed by #3539
Assignees
Labels
feat Issue is a feature

Comments

@danielbate
Copy link
Member

danielbate commented Jan 3, 2025

#3495 proposes a way of optimising perceived transaction speed through pre-bundling dependencies. However, as shown in #3513 this process can be simplified.

Currently, costing and funding transaction request looks like:

const txRequest = new ScriptTransactionRequest();
const txCost = await wallet.getTransactionCost(txRequest);
txRequest.maxFee = txCost.maxFee;
txRequest.gasLimit = txCost.gasUsed;
await wallet.fund(txRequest, txCost);
const tx = await wallet.sendTransaction(txRequest);
await tx.waitForResult();

This process is neater with a contract call:

const call = contract.functions.echo_b256(ADDRESS_B256);
const txRequest = await call.fundWithRequiredCoins();
const tx = await wallet.sendTransaction(txRequest);
await tx.waitForResult();

We should implement the following:

  • Introduce a method (e.g. autoCost) purely for transaction requests that can cost and fund a transaction in a single call
  • Have parity between tx requests and contract calls for this flow

The proposed API would then look as follows:

const txRequest = new ScriptTransactionRequest().autoCost(wallet);
const tx = await wallet.sendTransaction(txRequest);
await tx.waitForResult();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Issue is a feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant