createBuyTransaction() or any other transaction-related method.
You can use this preview to show users key transaction details before they confirm by including it in your transaction flow UI.
For a reference implementation, check the Universal Accounts with Ethers repository, or live Demo.
Transaction Preview Overview
When you callcreateBuyTransaction() or similar methods, the SDK returns a structured preview object with key transaction details.
Hereโs a breakdown of the main fields included in this preview:
TypeScript
Previewing a Transaction (Example)
To see a real example, hereโs how you can create and log a buy transaction for $1 worth of $PARTI:page.tsx
This example uses
createBuyTransaction, but the same approach will apply to any transaction method supported by the SDK.Displaying Estimated Fees
The returned transaction object includes metadata such as sender and recipient addresses, tokens used, and estimated fees. Hereโs how to extract and display the estimated fees:page.tsx
We use
formatUnits from ethers.js, but feel free to use any formatting utility that fits your stack.Integrating the Transaction Preview
You can integrate the transaction preview however you like in your dApp. In the demo repository below, estimated fees are shown before the user confirms the transaction.Demo Repository
Check out the demo repository for a working example.
Full Transaction Preview Widget
The guide and demo app above focus on a minimal example that previews estimated fees only. For a more complete implementationโincluding sender and receiver addresses, token transfers, and detailed metadataโrefer to the extended widget below:TransactionDetailsWidget.tsx
Whatโs Next?
Explore the SDK reference for more details:SDK Reference
See more methods and usage patterns.
Supported Chains
View which chains are available.
