Read map value
Read map value

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

plug
database
5actions
  1. 1·Take

    Declaring index as a caller parameter, this step lets the caller name which token slot the run resolves at execution time.

  2. 2·Take

    A second parameter, sma_window, is declared here for the caller to supply the moving-average window length used downstream.

  3. 3·Read map value

    Keyed by index, the tokens map in socket storage is read, returning the token address stored at that slot.

  4. 4·Use

    Composing the Get Weight Target plug runs its logic inline to derive the target weight for the resolved token.

  5. 5·Set map value

    Writing that derived weight into the weights map in socket storage at the index slot records the computed target weight for the token.

Take
Take
Read map value of in in
Use where
tokenis
windowis
Set map value of in in to
  • Set SMA Weight

    plug
    database
  • Raw Weights to Percents

    plug
    evm
    boolean
  • Rebalance Holdings to Target

    plug
    values
    evm
  • Get Token Target

    plug
    database
    evm
  • Get Total Holdings Value

    plug
    evm
    boolean