How to Manually Construct a Swap Message through act

This guide explains how to manually assemble a message for a swap transaction on dedust.io through act.

Swap Message Structure

The swap message consists of:

SwapParams Structure

The SwapParams structure consists of the following fields:

1. Building the SwapParams

Manual Code

beginCell()
  .storeUint(now() + 5 * 60, 32) // Deadline
  .storeAddress(myAddress()) // Recipient address
  .storeUint(0, 2) // Referral (if any)
  .storeBit(0) // Fulfill payload (optional)
  .storeBit(0) // Reject payload (optional)
.endCell();
                

Dedust Reference

Refer to Dedust Docs for additional swap message structures.

SwapParams [docs]

swap_params#_ deadline:Timestamp recipient_addr:MsgAddressInt referral_addr:MsgAddress fulfill_payload:(Maybe ^Cell) reject_payload:(Maybe ^Cell) = SwapParams;

Act Interface

Act Interface

2. Building the Swap Message

Manual Code

beginCell()
  .storeUint(0xea06185d, 32) // Swap op-code
  .storeUint(0, 64) // Query ID
  .storeCoins(amount - toNano(0.2)) // Amount minus fee
  .storeAddress("EQDQ...XJWC") // dedust_pool address
  .storeUint(0, 1) // Swap kind
  .storeCoins(0) // Minimum output of the swap
  .storeBit(0) // Reference to the next step
  .storeRef(swap_params) // Reference to SwapParams
.endCell();
                

Dedust Reference

Refer to Dedust Docs for additional swap message structures.

Message "swap" [docs]

swap#ea06185d query_id:uint64 amount:Coins _:SwapStep¹ swap_params:^SwapParams² = InMsgBody;

SwapStep [docs]

step#_ pool_addr:MsgAddressInt params:SwapStepParams = SwapStep;

step_params#_ kind:SwapKind limit:Coins next:(Maybe ^SwapStep) = SwapStepParams;

Act Interface

Act Interface

3. Sending the Message

Once the message is constructed, send it to the contract using your preferred wallet / script / act interface.

🎥 Also, enjoy the video: