Database

Set stored value and read stored value on Database

Ethereum
Ethereum
Base
Base
Storage

Ready to run on Base

Persistent state is the primitive every serious plan needs and almost no automation gets: a place to put a number down at the end of one run and pick it back up at the start of the next, onchain, without a server, a cron job, or a spreadsheet holding the truth off to the side.

The database gives a plug durable memory with real scope rules. A value can belong to the wallet, to a single plug, or to the exact version of a plug, so two automations never trample each other's numbers and a rewritten strategy does not inherit stale state from the one it replaced. Plain values, keyed maps, and nested maps cover everything from a single high-water mark to a full ledger of what happened per token per day.

That is the difference between a plug that reacts and a plug that remembers. A cost basis written when the position opened and compared against on every run since. A counter that caps how many times a rule may fire. The last price a strategy acted on, kept so it only acts again when the move is real. State written on one run steers every run after it, and no person has to carry the number in their head in between.

Plans without memory repeat themselves; plans with memory compound. The strategies worth automating are the ones that know what they did last time, and this is where they keep that knowledge.

How to set stored value and read stored value on Database

  • Writes a value to the socket's persistent storage under a scope and key.

    Reach for it to persist anything a later run needs: a running total, the timestamp of the last rebalance, a cap consumed so far.

  • Reads a stored value from the socket's persistent storage by key.

    Reach for it to carry state between executions, such as the last execution price, a running total, or a cursor, and feed it into a comparison or calculation in the next step.

  • Reads a value from a keyed map in the socket's persistent storage.

    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.

  • Writes a value into a keyed map in the socket's persistent storage.

    Reach for it to record per-token or per-user state across executions, such as the amount deployed into each market or the last run for each recipient, so later runs read it back and act on it.

  • Reads a value from a two-level keyed map in the socket's persistent storage.

    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.

  • Writes a value into a two-level keyed map in the socket's persistent storage.

    Reach for it to record two-dimensional state across executions, like how much of each token has been sent to each recipient, so later runs read it back and enforce limits.

Posts · 9