-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstate-block-with-hash.example.ts
More file actions
29 lines (25 loc) · 1.18 KB
/
state-block-with-hash.example.ts
File metadata and controls
29 lines (25 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import z from "zod";
import { Nano } from "nano-sdk";
type StateBlockWithHash = z.infer<typeof StateBlockWithHash>;
const StateBlockWithHash = Nano.Blocks.StateBlock().extend({
hash: Nano.Types.HashString(),
});
const stateBlock: StateBlockWithHash = {
hash: "523F8240320ACA742BEE4A1223FFE35E5B88BFAA2D179E89AD71A5C9A3AE456C",
type: "state",
account: "nano_3gzkxkbc6jpinataxe19jt57thasr8waatbxdhzpe4utcfo19ojbdnocoyee",
previous: "0000000000000000000000000000000000000000000000000000000000000000",
representative: "nano_3jgm64cjcyo4z5qffeneyfkinypaimdebro697t6fc5prc6jtoy8797yyci7",
balance: "1000000000000000000000000000000001",
link: "994FB51A40E516B8BC82299CDC71575A2F8E5ACFAB090EC963EAFE596A940E32",
link_as_account: "nano_38chpnf63sapq4ya6cewujrogpjhjsfezcrb3u6p9tqyd7oba5jkx5irysno",
signature:
"6B6F2E7084758376BDDAC947E31DCFEDC055F1DA98C5DC0169AF4D5A53376BE1791C3D0C6989D19172BDFBB4DDA840C5422A49E73F8EB5E62315576E4FAD150B",
work: "7b7ca1f0bf86cee4",
};
const parsed = StateBlockWithHash.safeParse(stateBlock);
if (parsed.success) {
console.log("Hash:", parsed.data.hash); // prints "Hash: 1700000000"
} else {
console.error("Validation failed:", parsed.error.issues);
}