fetch-logo
ConceptsConceptsGuidesGuidesExamplesExamplesReferencesReferencesAPIsAPIs
GitHub (opens in a new tab)
  • References
        • Almanac contract overview
        • Registration and endpoints weighting
    • Ledger
      • Versions
      • Active networks
      • Mainnet archives
      • Validators security
    • Indexer
      • Endpoints / Playground UIs
      • Querying
      • Entities
      • Versioning
  • References
        • Almanac contract overview
        • Registration and endpoints weighting
    • Ledger
      • Versions
      • Active networks
      • Mainnet archives
      • Validators security
    • Indexer
      • Endpoints / Playground UIs
      • Querying
      • Entities
      • Versioning

Agents storage

Agents storage is an important concept to understand how agents work within the uAgents Framework. You can use the Context object to modify storage information related to your agent. While writing the code for your agent, you can add within an event handler, different methods retrieved using ctx (i.e., the agent's Context object) to retrieve and edit storage values.

For instance, you could use the set method of the Context object to set the agent's local storage by simply running:

ctx.storage.set("key", "value")

This will save the information in a JSON file. This information can be retrieved at any time using the get method of the Context object:

ctx.storage.get("key")

For a practical understanding of the concept of storage, have a look at the Using agents storage function ↗️ guide in the Agents guides ↗️ section for a step-by-step example showing how to retrieve and set storage values.

The How to book a table at a restaurant using agents ↗️ and the How to use the agents to simulate a cleaning scenario ✨ ↗️ guides in the Agents guides ↗️ section, instead, shows a more complex and real-world demonstrations making use of the agent's storage concept.

Was this page helpful?

Introduction to Fetch.ai
footer-logo

Main website

Integrations

Events

We’re hiring!

Twitter (opens in a new tab)Telegram (opens in a new tab)Discord (opens in a new tab)GitHub (opens in a new tab)Youtube (opens in a new tab)LinkedIn (opens in a new tab)Reddit (opens in a new tab)
Sign up for developer updates