apps/docs/src/guide/transactions/assemble-tx-migration-guide.md
The old methods of estimating and funding transaction were deprecated in favor of a more robust provider.assembleTx. This guide will help you migrate your code to use the new method.
getTransactionCost and fund<<< @./snippets/assemble-tx/get-cost-and-fund-1.ts#get-cost-and-fund-1{ts:line-numbers}
<<< @./snippets/assemble-tx/assemble-tx-3.ts#assemble-tx-3{ts:line-numbers}
Consider the following Sway script
<<< @/../../docs/sway/script-transfer-to-contract/src/main.sw#custom-transactions-1{rust:line-numbers}
This script transfers two asset amounts to the same contract address. To ensure the transaction succeeds, it must be properly funded with the required amounts. This means we need to explicitly define how the transaction should be funded.
<<< @./snippets/assemble-tx/get-cost-and-fund-2.ts#get-cost-and-fund-2{ts:line-numbers}
<<< @./snippets/assemble-tx/assemble-tx-4.ts#assemble-tx-4{ts:line-numbers}
By specifying which parameters assembleTx should use, we gain control over how the script call is estimated and funded.
estimateAndFund<<< @./snippets/assemble-tx/estimate-and-fund-2.ts#estimate-and-fund-2{ts:line-numbers}
<<< @./snippets/assemble-tx/assemble-tx-2.ts#assemble-tx-2{ts:line-numbers}
More Explicit Control: assembleTx provides clearer control over which account pays fees and which accounts provide resources.
Better Resource Management: The new method allows you to specify exactly which accounts should provide which quantities of assets.
Controlling Change Output: When informing each account coin quantity you have control over determining who is going to receive a the change for that specific asset ID.
getTransactionCost and estimateAndFund are deprecated and are going to be removed on futures updatesThe new assembleTx method provides several additional options:
<<< @/../../../packages/account/src/providers/provider.ts#assemble-tx-params{ts:line-numbers}
You can read more about the assembleTx here.