Craft Transaction without SDK
Create Swap Intent
SwapIntentDatum Structure
// Aiken
pub type SwapIntentDatum {
account_address: Address, // User's address to receive output tokens
from_amount: MValue, // Assets user is selling
to_amount: MValue, // Minimum assets user expects to receive
created_at: Int, // Slot number (used for cancellation timing)
deposit: Lovelace, // Min UTxO deposit in lovelace (typically 2000000)
}
pub type MValue = Pairs<PolicyId, Pairs<AssetName, Int>>// Type definition (imported from @meshsdk/core)
type SwapIntentDatum = ConStr0<
[
PubKeyAddress | ScriptAddress, // account_address
Pairs<PolicyId, Pairs<AssetName, Integer>>, // from_amount (MValue)
Pairs<PolicyId, Pairs<AssetName, Integer>>, // to_amount (MValue)
Integer, // created_at (slot)
Lovelace, // deposit
]
>;
// Constructor function that builds a SwapIntentDatum for on-chain storage
const datum = swapIntentDatum({
accountAddress: "addr_test1...",
fromAmount: [{ unit: config.tokens.night, quantity: "100000000" }],
toAmount: [{ unit: config.tokens.usdm, quantity: "5000000" }],
createdAt: 12345678,
deposit: 2000000, // optional, default 2 ADA
});The transaction must
Example Datum
Cancel Swap Intent
CancelIntent Redeemer
The transaction must
Last updated