set
Call v101 → current #0Sets the current on-chain time; called exactly once per block by validators.
View calls on chainCall Workflow
Click items to navigate. Pan and zoom to explore.
The Big Picture
Blockchains have no native concept of time - they only know block numbers. The Timestamp pallet bridges this gap by allowing validators to set the current Unix timestamp in each block. This timestamp becomes the canonical on-chain time used by all other pallets and contracts that need time-based logic.
Why This Matters
Many blockchain operations need real-world time: vesting schedules, auction deadlines, rate limiting windows. The timestamp pallet provides this fundamental infrastructure. You don't call this directly - validators do it automatically as part of block production.
Example Scenario
Every block includes an inherent timestamp extrinsic. At block 1000000, the validator calls set(now=1704067200000) - Unix milliseconds for Jan 1, 2024. Any pallet or contract can now query Timestamp.Now to get 1704067200000.
Common Questions
- Can regular users call this?
- No. This is an inherent extrinsic with None origin - only the block author (validator) can include it, and they must include it or the block fails.
- How accurate is on-chain time?
- Reasonably accurate but not precise. Validators use their local clock, and MinimumPeriod prevents going backwards. Expect accuracy within seconds, not milliseconds.
- What happens if a validator sets a wrong time?
- MinimumPeriod prevents timestamps from going backwards or jumping too little. Consensus mechanisms also constrain allowed time ranges to prevent abuse.
Use Cases
- Provide on-chain time reference for all block operations
- Enable time-based logic in smart contracts and pallets
- Coordinate block timing with consensus mechanism
From Chain Metadata
Set the current time. This call should be invoked exactly once per block. It will panic at the finalization phase, if this call hasn't been invoked by that time. The timestamp should be greater than the previous one by the amount specified by `MinimumPeriod`. The dispatch origin for this call must be `Inherent`. ## Complexity `O(1)` (Note that implementations of `OnTimestampSet` must also be `O(1)`) 1 storage read and 1 storage mutation (codec `O(1)`). (because of `DidUpdate::take` in `on_finalize`) 1 event handler `on_timestamp_set`. Must be `O(1)`.
Input Parameters
| # | Name | Type | Description |
|---|---|---|---|
| 0 | now → timestamp | Compact<u64> Cpt | Unix timestamp in milliseconds to set as current block time (SCALE compact -> integer) |
Permissions
Permission data inferred from metadata. May be incomplete.
Requirements
- Call must originate from None (inherent extrinsic)
- Must be called exactly once per block
- Timestamp must be greater than previous by at least MinimumPeriod
Effects
Code Examples
import { ApiPromise, WsProvider } from "@polkadot/api";
import { stringCamelCase } from "@polkadot/util";
const provider = new WsProvider("wss://entrypoint-finney.opentensor.ai:443");
const api = await ApiPromise.create({ provider });
// Build set call
const now = 0;
const call = api.tx[stringCamelCase("Timestamp")][stringCamelCase("set")](
now
);On-Chain Activity
Primary protocol calls
#6 most used call
Over 95% of submissions succeed
As of block 7,429,232
Runtime Info
- Pallet Index
- 2
- Call Index
- 0
- First Version
- v101
- Current Version
- v393