Skip to main content
added 1 character in body; edited tags
Source Link

Solana Rust smart contractsonchains program have access to

solana_program::clock::Clock::get()?.unix_timestamp

which is seconds from epoch (midnight Jan 1st 1970 GMT) but has a significant drift from any real-world time-zone as a product of Solana's slowdowns over time. Many contracts factor in this unix timestamp when calculating reward amounts (notably Step Finance and therefore Gem Farm which reuses the logic). How can I reconstruct this Solana unix timestamp on the front-end in JavaScript without requiring any transaction / wallet signature? Calls to a Solana node RPC are fine.

Solana Rust smart contracts have access to

solana_program::clock::Clock::get()?.unix_timestamp

which is seconds from epoch (midnight Jan 1st 1970 GMT) but has a significant drift from any real-world time-zone as a product of Solana's slowdowns over time. Many contracts factor in this unix timestamp when calculating reward amounts (notably Step Finance and therefore Gem Farm which reuses the logic). How can I reconstruct this Solana unix timestamp on the front-end in JavaScript without requiring any transaction / wallet signature? Calls to a Solana node RPC are fine.

Solana Rust onchains program have access to

solana_program::clock::Clock::get()?.unix_timestamp

which is seconds from epoch (midnight Jan 1st 1970 GMT) but has a significant drift from any real-world time-zone as a product of Solana's slowdowns over time. Many contracts factor in this unix timestamp when calculating reward amounts (notably Step Finance and therefore Gem Farm which reuses the logic). How can I reconstruct this Solana unix timestamp on the front-end in JavaScript without requiring any transaction / wallet signature? Calls to a Solana node RPC are fine.

Source Link
Rajat
  • 147
  • 1
  • 5

How to get the Solana unix_timestamp on the front-end (in JavaScript)?

Solana Rust smart contracts have access to

solana_program::clock::Clock::get()?.unix_timestamp

which is seconds from epoch (midnight Jan 1st 1970 GMT) but has a significant drift from any real-world time-zone as a product of Solana's slowdowns over time. Many contracts factor in this unix timestamp when calculating reward amounts (notably Step Finance and therefore Gem Farm which reuses the logic). How can I reconstruct this Solana unix timestamp on the front-end in JavaScript without requiring any transaction / wallet signature? Calls to a Solana node RPC are fine.