
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
First the plug declares a caller-supplied parameter named index, whose value arrives at execution time.
2·Take
Next it declares a second caller-supplied parameter named sma_window, also filled in by the caller when the plug runs.
3·Read map value
Reading from the socket's persistent storage, this step looks up the tokens map using the key held in slot 0.0, which is the index parameter, and returns the stored value for that key.
4·Use
Then it composes the plug Get Weight Target inside this one, running its logic as part of this transaction.
5·Set map value
Finally it writes into the weights map in socket storage, using the index parameter as the key and setting the entry to the value produced in slot 3.0 by the composed Get Weight Target plug.