Skip to content

Conversation

@heliuchuan
Copy link
Contributor

@heliuchuan heliuchuan commented Aug 4, 2025

Description

This adds a TransactionManager to make interacting with the Aptos blockchain much easier.

Before

const config = new AptosConfig({ network: Network.DEVNET });
const aptos = new Aptos(config);
await aptos.fundAccount({
  accountAddress: alice.accountAddress,
  amount: ALICE_INITIAL_BALANCE,
});
const transaction = await aptos.transferCoinTransaction({
  sender: alice.accountAddress,
  recipient: bob.accountAddress,
  amount: TRANSFER_AMOUNT,
});
const pendingTxn = await aptos.signAndSubmitTransaction({ signer: alice, transaction });
const response = await aptos.waitForTransaction({ transactionHash: pendingTxn.hash });

After

const config = new AptosConfig({ network: Network.DEVNET });
const txnManager = TransactionManager.new(config).defaultSender(alice);
await txnManager.fundAccount().submit();
const response = await txnManager
  .transferCoinTransaction({
    recipient: bob.accountAddress,
    amount: TRANSFER_AMOUNT,
  })
  .submit();

See updated typescript examples in this PR for examples.

Test Plan

Related Links

Checklist

  • Have you ran pnpm fmt?
  • Have you updated the CHANGELOG.md?

@heliuchuan heliuchuan requested a review from a team as a code owner August 4, 2025 20:09
Copy link
Collaborator

@0xmaayan 0xmaayan left a comment

Choose a reason for hiding this comment

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

  • Looks like there is no option to simulate a transaction?
  • This flow only really supports signAndSubmit as a one step, what if I only want to generate a transaction and then sign it as two separate steps?
  • Similarly, Wallets use the sdk with the generate->simulate->submit flow - I dont think this flow supports it?
  • submit() by default waits for transaction - what if I dont want to wait for it?
  • I am not completely sure what this flow tries to solve? it looks like it is more of a personal preference of code writing.
  • On this ^ topic, things like registerName(), renewDomain() feel a bit confusing to me, I think having aptos.ans.registerName() is more explanatory and meaningful for external devs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants