uAgents Protocols
uAgents Storage

uAgents Storage

uAgents storage is an important concept to understand how uAgents work. You can use the Context object to modify storage information related to your uAgent. 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 uAgent's local storage by simply running:"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:"key")

For a practical understanding of the concept of storage, have a look at the Using uAgents storage function ↗️ guide in the uAgents 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 uAgents ↗️ guide in the uAgents guides section, instead, shows a more complex and real-world demonstration making use of the uAgent's storage to store a table information in a restaurant.