Skip to content

Fix deploy output min ADA: apply Babbage/Conway UTxO entry overhead formula#32

Merged
SynthLuvr merged 4 commits into
mainfrom
copilot/fix-insufficient-funding-outputs
Mar 1, 2026
Merged

Fix deploy output min ADA: apply Babbage/Conway UTxO entry overhead formula#32
SynthLuvr merged 4 commits into
mainfrom
copilot/fix-insufficient-funding-outputs

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 1, 2026

The deploy transaction output was underfunded because the SDK's calculateMinimumUtxoLovelace omits the 160-byte UTxO entry overhead mandated by the Babbage/Conway ledger formula, and seeding it with Assets.zero produces a CBOR size 4 bytes smaller than the actual output (0 lovelace = 1-byte CBOR vs. any typical min value ≥ 65536 = 5-byte CBOR). Result: 1,913,640 lovelace submitted vs. 2,620,480 required.

Changes

  • src/mint.ts — Replace direct calculateMinimumUtxoLovelace call with a two-step calculation:
    • Pass coinsPerUtxoByte: 1n to obtain the raw CBOR byte count rather than a lovelace amount
    • Use Assets.fromLovelace(1_000_000n) as a placeholder so the lovelace field serializes with the same 5-byte CBOR encoding as the final value
    • Apply the correct ledger formula manually: (cborSize + 160n) * coinsPerUtxoByte
const cborSize = await Effect.runPromise(
  calculateMinimumUtxoLovelace({
    address: blackholeAddr,
    assets: Assets.fromLovelace(1_000_000n),
    scriptRef: script,
    coinsPerUtxoByte: 1n,
  })
);
const minLovelace = (cborSize + 160n) * coinsPerUtxoByte;
// (448 + 160) × 4310 = 2,620,480 ✓

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: SynthLuvr <131367121+SynthLuvr@users.noreply.github.com>
Comment thread src/mint.ts Outdated
Copilot AI changed the title [WIP] Fix insufficiently funded transaction outputs Fix insufficient ADA on script deploy output Mar 1, 2026
…y tx

Co-authored-by: SynthLuvr <131367121+SynthLuvr@users.noreply.github.com>
Comment thread src/mint.ts
Copilot AI changed the title Fix insufficient ADA on script deploy output Replace hardcoded deploy ADA with dynamic min UTxO calculation; drop unnecessary datum Mar 1, 2026
Co-authored-by: SynthLuvr <131367121+SynthLuvr@users.noreply.github.com>
Copilot AI changed the title Replace hardcoded deploy ADA with dynamic min UTxO calculation; drop unnecessary datum Fix deploy output min ADA: apply Babbage/Conway UTxO entry overhead formula Mar 1, 2026
@SynthLuvr SynthLuvr marked this pull request as ready for review March 1, 2026 20:40
@SynthLuvr SynthLuvr merged commit 8bb5709 into main Mar 1, 2026
1 check passed
@SynthLuvr SynthLuvr deleted the copilot/fix-insufficient-funding-outputs branch March 1, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants