How market orders differ from limit orders
| Market order | Limit order | |
|---|---|---|
| Price | Any ([1, denominator]) | Specified ratio |
| Execution fee | 0.6 ADA (1 × 0.6 ADA) | 1.8 ADA (3 × 0.6 ADA) |
| Beacon prefix | 0x01 | 0x00 |
| Fills when | Next available batcher run | Market price reaches your price |
Price field
Set theprice field in the datum to accept any price:
numerator = 1 signals infinite slippage — the order fills regardless of the current market price.
- Buy (ADA → token)
- Sell (token → ADA)
Buying a token with ADA at any price:
Execution fee
Market orders require 1 execution step, so the total fee is:Transaction structure
Inputs
Any user UTxOs to cover:- Input asset amount (what you are selling)
- Transaction fees
- Order collateral (minimum 2 ADA)
- Deposit ADA for outputs
Order output
Send to the script address constructed from the script hash and optionally your stake credentials. Output value:| Asset | Amount |
|---|---|
| Input asset | inputAmount |
| ADA (execution fee) | 0.6 ADA |
| ADA (deposit) | depositAdaForOrder + depositAdaForReceive |
| ADA (collateral) | Additional if total < 2 ADA |
| Component | Amount |
|---|---|
| Input asset | 50 ADA |
| Execution fee | 0.6 ADA |
| UTxO deposit | ~1.5 ADA |
| Receiving deposit | ~1.5 ADA |
| Additional collateral | 0 ADA (total already > 2) |
| Total | ~53.6 ADA |
Datum
Build the datum the same way as a limit order, with two differences:- Set
priceto[1, denominator] - The beacon prefix byte is
0x01(market)
Transaction building flow
Build datum
Set
price: [1, inputAmount] and all other fields except beacon. See datum building.Calculate beacon
Use the first input UTxO reference and order index with
orderType = 'market'. Beacon prefix byte is 0x01. See beacon calculation.Important notes
The beacon calculation uses the first transaction input. Add the UTxO to transaction inputs before calculating the beacon.
- Order index must match the actual index of the order output in the transaction outputs array.
- Minimum collateral — total deposits must be at least 2 ADA.
- Stake credentials are optional but recommended.
- Asset format — ADA is
["", ""], tokens are[policyId, tokenName]in hex. - Cancellation — market orders can be cancelled before execution. See order cancel.