
Database · Acts onchain
Reads a value from a keyed map in the socket's persistent storage. The map and key are both bytes32, so any value can serve as the key: a token address, a user address, an interval bucket. 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 to keep per-token or per-user records across executions, such as the last price seen for each asset, and branch on them with a predicate in the same transaction.
Set SMA Weight


1·Take
The index parameter is declared first, letting the caller name which token slot this plug writes a weight for at execution time.
2·Take
Alongside it, sma_window is declared as a caller parameter, supplying the moving-average window the composed step below uses.
3·Read map value
Keyed by index, the tokens map in socket storage is read, returning the token stored at that slot position.
4·Use
Composing the Get Weight Target plug runs its logic inline to derive the weight value for that token over the given window.
5·Set map value
Writing that derived weight into the weights map in socket storage at index records the new weight for the resolved slot.