Copy
Ask AI
import * as ForkId from 'voltaire-effect/primitives/ForkId'
import * as Schema from 'effect/Schema'
import { Effect } from 'effect'
// Schema validation
const forkId = Schema.decodeSync(ForkId.JSON)({
hash: new Uint8Array([0xfc, 0x64, 0xec, 0x04]),
next: 1150000n
})
// Effect constructor
const program = ForkId.from({
hash: new Uint8Array([0xfc, 0x64, 0xec, 0x04]),
next: 1150000n
})
const result = Effect.runSync(program)
console.log(result.hash, result.next)
Input Type
Copy
Ask AI
type ForkIdInput = {
hash: Uint8Array // 4 bytes
next: bigint | number
}
Error Handling
Copy
Ask AI
const result = await Effect.runPromiseExit(
ForkId.from({ hash: new Uint8Array([]), next: -1n })
)
// result._tag === 'Failure' → ForkIdError

