Get duration

Get duration on Values

Ethereum
Ethereum
Base
Base

Reads onchain state

Ready to run on Base

Converts a count of time units into seconds. Units are seconds, minutes, hours, days, weeks, months, and years; months are 30 days and years are 365. Reach for it to build a deadline offset from the current timestamp, to compare an elapsed delta against a required interval, or to size a cooldown for a stored timestamp check.

Plug lets you combine onchain actions like this one into a single transaction, without writing a smart contract. Use in App opens a new plug with this action already in it.

Get Price Running Total

plug
values
math
9actions
  1. 1·Take

    Declares token, a named parameter the caller supplies at execution time.

  2. 2·Take

    Declares today, a caller-supplied parameter, at execution time.

  3. 3·Take

    Adds days_back as a named parameter the caller provides when running.

  4. 4·Take

    Declares price_running_total, the final caller-supplied parameter.

  5. 5·Get duration

    Converts days_back into seconds using the fixed multiplier 0x015180, producing that span in seconds.

  6. 6·Calculate

    Subtracts the day-span-in-seconds from today, yielding an earlier timestamp.

  7. 7·Read nested map value

    Reads the nested map value keyed by token and the earlier timestamp from sma in socket storage.

  8. 8·Calculate

    Adds the stored sma value to price_running_total, accumulating the running total.

  9. 9·Bubble

    Surfaces the accumulated running total as this plug's output.

Take
Take
Take
Take
Get as seconds
Calculate
Read nested map value of in in
Calculate
Bubble

More plugs on Base

Bridge from Base · 6 plugs

Posts · 2

More on Values · 6