Skip to content

Commit 5ee95bc

Browse files
committed
docs: add changeset
1 parent f8ada82 commit 5ee95bc

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

.changeset/seven-parts-warn.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
"@evolution-sdk/evolution": patch
3+
---
4+
5+
## hashPlutusData encoding options
6+
7+
Add optional CBOR encoding options parameter to `hashPlutusData` function. This allows controlling how Plutus data is encoded before hashing, which affects the resulting datum hash.
8+
9+
**Before:**
10+
11+
```typescript
12+
import { hashPlutusData } from "@evolution-sdk/evolution/utils/Hash"
13+
14+
// Always uses indefinite-length encoding (CML_DATA_DEFAULT_OPTIONS)
15+
const hash = hashPlutusData(data)
16+
```
17+
18+
**After:**
19+
20+
```typescript
21+
import { Core } from "@evolution-sdk/evolution"
22+
import { hashPlutusData } from "@evolution-sdk/evolution/utils/Hash"
23+
24+
const cborHex = "d87983486c6f76656c6163655820c3e43c6b8fb46068d4ef9746a934eba534873db0aacebdaf369c78ab23cb57751a004c4b40"
25+
const decoded = Core.Data.fromCBORHex(cborHex)
26+
27+
// Indefinite-length (SDK default for Data)
28+
const indefiniteHash = hashPlutusData(decoded, Core.CBOR.CML_DATA_DEFAULT_OPTIONS)
29+
console.log("Hash:", Core.Bytes.toHex(indefiniteHash.hash))
30+
// b67b6e7d2497d4e87a240a080a109a905f73527a244775cc1e2a43f48202700f
31+
32+
// Definite-length encoding
33+
const definiteHash = hashPlutusData(decoded, Core.CBOR.CML_DEFAULT_OPTIONS)
34+
console.log("Hash:", Core.Bytes.toHex(definiteHash.hash))
35+
// bc7eea92ba15710926e99904e746e5da739d77085b6192ddd87a0e7b4298e0c0
36+
37+
// Aiken-compatible encoding
38+
const aikenHash = hashPlutusData(decoded, Core.CBOR.AIKEN_DEFAULT_OPTIONS)
39+
console.log("Hash:", Core.Bytes.toHex(aikenHash.hash))
40+
// b67b6e7d2497d4e87a240a080a109a905f73527a244775cc1e2a43f48202700f
41+
```

0 commit comments

Comments
 (0)