Ogmios: represent 64-bit amounts as bigint with lossless JSON to avoid precision loss
Maintainers usually reply within 1 day
@emmanuel-musau is already working on this.
Since Sep 28, 2026.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- typescript
Research direction
Start in packages/evolution/src/sdk/provider/internal/Ogmios.ts, focusing on the affected amount types and toOgmiosUTxOs, then inspect HttpUtils.postJson for request and response serialization. Trace the additionalUtxo path from KupmiosEffects.ts and KoiosEffect.ts. Done means the regression case preserves 2^64-1 and 2^53+1 as exact, unquoted JSON numbers and inbound amount parsing is lossless.
Written by the indexing model from the issue text.
Description
Summary
The Ogmios provider converts 64-bit Cardano amounts (lovelace and native-token quantities) with Number(...), but a JS number is exact only to 2^53-1. Cardano amounts are uint64, so any value above 2^53 is silently corrupted. Every other provider uses BigInt(...), and the SDK models Coin as Schema.BigInt up to 2^64-1, so this is an inconsistent defect. The corrupted values are sent to Ogmios as the additionalUtxo set during transaction evaluation, producing wrong ex-units/fees and on-chain rejection for transactions involving high-supply tokens. Fail closed: no fund loss, the tx is just rejected.
Affected
packages/evolution/src/sdk/provider/internal/Ogmios.ts: OgmiosAssets type (L128), Value type (L130-132), toOgmiosUTxOs Number(quantity) (L189) and Number(lovelace) (L216), inbound LovelaceAsset schema (L24-26), Delegation rewards/deposit (L118-119)
reached via: KupmiosEffects.ts:380 and KoiosEffect.ts:325 (additionalUtxo for evaluateTransaction)
transport: HttpUtils.postJson (bodyJson -> JSON.stringify on send; response.json -> JSON.parse on receive)
contrast (correct): Koios.ts:292/298, Maestro.ts toBigInt, Blockfrost.ts
Fix
Represent Ogmios amounts as bigint end to end (OgmiosAssets -> Record<string, Record<string, bigint>>, Value.ada.lovelace -> bigint, drop Number(...) in toOgmiosUTxOs).
Important: Ogmios encodes amounts as UNQUOTED JSON numbers (per the Ogmios v6 API, e.g. { "ada": { "lovelace": 1234 } }), so:
- on send, a bigint cannot go through JSON.stringify; emit it as a bare JSON numeric literal via a lossless serializer (json-bigint style or a replacer that splices the integer), not as a quoted string (Ogmios will reject a string).
- on receive, response.json uses standard JSON.parse which truncates above 2^53 before the schema, so any inbound amount field that can exceed 2^53 needs a big-int-aware parser, not just a BigInt schema. (The evaluate response is only ex-units, which are small, so the live issue is the send path; fix the receive path too for correctness on amount-bearing Ogmios queries.)
Regression test
- given: a UTxO with token quantity 2^64-1 and lovelace 2^53+1, run toOgmiosUTxOs([utxo]) and serialize the additionalUtxo body the same way the request does
- before fix: amounts are corrupted (2^64-1 -> 18446744073709552000, 2^53+1 -> 2^53)
- after fix: the serialized payload contains the exact integers as unquoted JSON numbers, round-tripping unchanged
Must FAIL on main today and PASS after the fix.
Reference
GHSA-mrqw-3c7x-96mg
- Dominant language
- TypeScript
- Stars
- 22
- Forks
- 33
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 36
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from IntersectMBO/evolution-sdk
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
IntersectMBO/evolution-sdk#601 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
IntersectMBO/evolution-sdk#559 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
IntersectMBO/evolution-sdk#557 ·
Maintainers usually reply within 1 day
-
dependencies good first issue
Difficulty 1/5 Under an hour Newbie friendliness 93/100
IntersectMBO/evolution-sdk#541 ·
Maintainers usually reply within 1 day
-
bug external-review
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
IntersectMBO/evolution-sdk#530 ·
Maintainers usually reply within 1 day
All issues in IntersectMBO/evolution-sdk
Similar issues
-
refactor
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
tomnewport/memprot-topo#55 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
WalletConnect/walletconnect-monorepo#7368 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
BU-Spark/se-chem-apll#47 ·
-
embed: handleTurboSignMessage header comment says the signing page posts to '*' (it never does)Opendocumentation
Difficulty 2/5 Under an hour Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 Half a day Newbie friendliness 70/100
udistrital/paginaweb_root#23 ·