Introducing the Dynamic Script Composer on Aptos
By Runtian Zhou

We’re excited to announce Dynamic Script Composer, a new feature in our TypeScript SDK that lets you build complex Aptos transactions without directly writing Move scripts. Instead of deploying new on-chain modules for each workflow, you can now chain actions like token swaps, transfers, or deposits entirely in TypeScript. Under the hood, our SDK compiles your instructions into Move scripts using Rust and WASM for faster development, experimentation and powerful transaction flows.
If you are interested in using the Script Composer right away, head over to the documentation. Here we discuss background and high-level design.
Background and Motivation
Currently, most Aptos developers create transactions by invoking entry functions — Move functions explicitly defined as transaction entry points. While this is simple and sufficient for many use cases, it can become limiting if you need to perform multiple actions in a single transaction.
For example, say you want to:
- Draft funds from an account,
- Swap them in a liquidity pool,
- Take the swapped tokens and do another swap,
- Finally deposit the tokens into a lending protocol.
Achieving all of these steps in a single transaction would normally require you to write and deploy specialized Move scripts or modules. But what if you could chain these actions together off-chain and submit them as one transaction without needing new modules every time?
This is where Dynamic Script Composer comes in.
What Is the Dynamic Script Composer?
Dynamic Script Composer is a feature in our TypeScript SDK that allows you to create a sequence of actions (just like you would in a normal programming workflow) and turn them into a single executable transaction script. Rather than manually writing Move script code, you can simply use our TypeScript interface to specify the steps in your transaction.
Under the hood, our SDK compiles this sequence into a Move Script payload using Rust, bundles it into a WebAssembly (WASM) binary, and finally wraps it for easy use in TypeScript. The result is a more straightforward and streamlined way to create complex, multi-step transactions.
Example Use Cases
- Chained swaps: Draft tokens from one account, swap on a DEX, and then chain the output to another DEX or protocol.
- Complex DeFi flows: Access multiple lending/borrowing protocols in a single transaction for an arbitrage or lending strategy.
- Custom multi-step logic: Execute multiple “regular” on-chain functions back-to-back without needing new code deployment.
Why This Approach?
Interestingly, everything the Dynamic Script Composer can do is already possible using the Move Script
payload feature. However, not all developers want — or need — to write Move scripts directly, and deploying new scripts or modules can create an additional barrier to experimentation.
By embedding a lightweight compiler into the TypeScript SDK, we drastically lower the learning curve. You can write your transaction logic in TypeScript, and we’ll handle turning it into a valid on-chain Script
behind the scenes.
How It Works (Behind the Scenes)
- Action Sequencing in TypeScript
You write a sequence of steps in TypeScript — perhaps function calls liketransfer()
,swap()
,deposit()
.These steps look very similar to how you’d call entry functions, but instead of immediately creating multiple separate transactions, you’re constructing a single logical flow. - Compilation to Move Script
Underneath, we have a Rust-based compiler that converts these action calls into valid Move script code. This Rust code is compiled into a WASM module so it can run in any JavaScript/TypeScript environment. - WASM Execution
The TypeScript SDK runs the WASM module to produce the final MoveScript
payload. This payload is then signed and submitted like any other transaction on Aptos. - On-chain Execution
When the transaction runs, the Move VM executes the chain of actions in a single atomic transaction, ensuring all or none of the actions succeed.
Comparison to On-Chain-Based Solutions
You might wonder: why not implement this entirely on-chain by modifying the transaction payload format and Move code to interpret it directly? There are three main reasons we chose off-chain compilation:
- Flexibility
The Move Script feature can express more advanced semantics (like passing mutable references between steps) without needing the on-chain code to handle custom logic. Off-chain compilation gives us powerful ways to structure transaction flows. - Safety
If we handled this on-chain, we’d have to re-implement a lot of what the Move VM already enforces: type safety, ability safety, reference safety, and more. Off-loading the complexity to Move’s existing compilation toolchain helps ensure security. - Upgradeability
By essentially creating a “DSL in TypeScript” to generate Move code, we can add new features and enhancements without coordinating with an on-chain release. This means more rapid iteration for developers, as all changes live in the SDK.
A Glimpse into the Future
This marks the Aptos team’s first attempt at embedding more complex Rust logic into our TypeScript SDK using WASM, and it opens up a world of possibilities. In the future, we might:
- Compile custom Move code directly in the TS SDK: Imagine writing new Move functionalities purely in TypeScript, letting the off-chain toolchain handle the heavy lifting of compilation and linking.
- Build more powerful DSLs: Our ultimate goal is to empower developers with the flexibility of Move without the overhead of writing and deploying raw Move scripts.
With this approach, we’re bridging the best of both worlds — easy off-chain programming and the full security and functionality of on-chain Move execution.
Get Started
Ready to try it out? Check out our SDK documentation to see how you can install the latest TypeScript package and start composing your own multi-step transactions today. We’d love to hear your feedback and see the workflows you build.
Stay tuned for more updates as we continue to expand the capabilities of Dynamic Script Composer and explore new ways to make developing on Aptos simpler, safer, and more powerful.
Happy building!