Time
Slots
Cardano slot numbers and time conversion
Slots
Cardano measures time in slots. Each slot has a fixed duration determined by the network's configuration. The transaction builder converts between Unix timestamps and slots using the slot config.
Slot Configuration
| Network | Slot Length | Start Time |
|---|---|---|
| Mainnet | 1000ms (1 second) | Shelley era start |
| Preprod | 1000ms (1 second) | Network genesis |
| Preview | 1000ms (1 second) | Network genesis |
| Devnet | Configurable (20-100ms typical) | Cluster creation |
How Conversion Works
The slot config defines three values:
- zeroTime — Unix timestamp of the network's start
- zeroSlot — First slot number (Shelley era)
- slotLength — Milliseconds per slot
The builder uses these to convert: slot = zeroSlot + (unixTime - zeroTime) / slotLength
Custom Slot Config
For devnet or custom networks, you can override the slot config in build options:
import { , , , } from "@evolution-sdk/evolution"
const = .()
.({
: "https://cardano-preprod.blockfrost.io/api/v0",
: ..!
})
.({ : ..!, : 0 })
const = await
.()
.({
: .("addr_test1vrm9x2dgvdau8vckj4duc89m638t8djmluqw5pdrFollw8qd9k63"),
: .(2_000_000n)
})
.({
: {
: 1666656000000n,
: 0n,
: 1000
}
})Manual Slot Conversion
The builder handles slot conversion automatically, but you can also convert manually using Time.unixTimeToSlot and Time.slotToUnixTime:
import { Time, SlotConfig } from "@evolution-sdk/evolution"
// Use built-in network configs
const preprodConfig = SlotConfig.SLOT_CONFIG_NETWORK.Preprod
const mainnetConfig = SlotConfig.SLOT_CONFIG_NETWORK.Mainnet
// Unix time → slot
const now = BigInt(Date.now())
const currentSlot = Time.unixTimeToSlot(now, preprodConfig)
console.log("Current slot:", currentSlot)
// Slot → Unix time
const targetSlot = 50000000n
const targetTime = Time.slotToUnixTime(targetSlot, preprodConfig)
console.log("Slot 50M is at:", new Date(Number(targetTime)))Available Network Configs
| Network | SlotConfig.SLOT_CONFIG_NETWORK.X | Zero Time | Zero Slot | Slot Length |
|---|---|---|---|---|
| Mainnet | .Mainnet | 1596059091000 (Shelley start) | 4492800 | 1000ms |
| Preprod | .Preprod | 1655769600000 | 0 | 1000ms |
| Preview | .Preview | 1666656000000 | 0 | 1000ms |
Next Steps
- POSIX Time — Unix timestamp utilities
- Validity Ranges — Setting time constraints