
Database · Acts onchain
Reads a value from a two-level keyed map in the socket's persistent storage. The outer and inner keys are both bytes32, so any values can serve, such as user then token. Scope chooses socket storage, shared by every plug the socket runs, or plug storage, private to this plug bundle. The read returns the committed value. Reach for it for two-dimensional records like per-user-per-token balances or per-market-per-interval history, then branch on the result with a predicate.
Get Price Running Total



1·Take
Declares token, a named parameter the caller supplies at execution time.
2·Take
Declares today, a caller-supplied parameter, at execution time.
3·Take
Adds days_back as a named parameter the caller provides when running.
4·Take
Declares price_running_total, the final caller-supplied parameter.
5·Get duration
Converts days_back into seconds using the fixed multiplier 0x015180, producing that span in seconds.
6·Calculate
Subtracts the day-span-in-seconds from today, yielding an earlier timestamp.
7·Read nested map value
Reads the nested map value keyed by token and the earlier timestamp from sma in socket storage.
8·Calculate
Adds the stored sma value to price_running_total, accumulating the running total.
9·Bubble
Surfaces the accumulated running total as this plug's output.