Transaction output layout
Fixed output indices used by simplicity-lending and mirrored in lwk-dart PRs #13/#15. Indices are 0-based.
IssuanceFactory creation
| Output | Content |
|---|---|
| 0 | Auth NFT (1 unit, wallet address) |
| 1 | Factory program UTXO (1 unit, covenant) |
| 2 | OP_RETURN — 13-byte creation metadata (program id, issuing_utxos_count, reissuance_flags) |
Lending offer creation (full tx)
Factory issuance outputs come first (auth NFT, factory, borrower NFT, lender NFT, protocol NFT…). Then attach_creation appends:
| Output | Content |
|---|---|
| 0–1 | Factory + auth (from issuance step) |
| 2 | Borrower NFT (1 unit) |
| 3 | Lender NFT (locked via ScriptAuth) |
| 4 | Protocol fee keeper NFT (when present) |
| 4 or 5 | OP_RETURN — 50-byte offer metadata (upstream: index 4) |
| 5 | Pending offer — collateral locked in LendingOffer covenant (upstream: index 5) |
50-byte offer metadata (OP_RETURN)
| Bytes | Field |
|---|---|
| 0–3 | Program id (first 4 bytes of SHA256 of source) |
| 4–35 | Principal asset id (32 bytes) |
| 36–43 | Principal amount (u64 LE) |
| 44–47 | Loan expiration block height (u32 LE) |
| 48–49 | Interest rate basis points (u16 LE) |
Collateral amount comes from the pending offer output value, not the metadata blob.
Indexer parsing
LendingOffer::try_from_tx reads outputs 2, 3, 5 and metadata at 4. Wrong indices → offers invisible to indexer even if tx confirms on-chain.