> For the complete documentation index, see [llms.txt](https://circular-protocol.gitbook.io/hyper-code-ide-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://circular-protocol.gitbook.io/hyper-code-ide-guide/lesson-3-wallet-access/custom-wallet-data.md).

# Custom Wallet Data

If the CRC\_Wallet implementation doesn’t meet our needs, we can easily store custom data within the wallet. To understand this better, let’s break down the OpenWallet and CloseWallet functions. In our current setup, we store two key pieces of information in the smart contract:

<mark style="color:green;">**Balance:**</mark> Tracks the number of tokens we own.

<mark style="color:green;">**Allowances Array:**</mark> Lists the tokens we’re authorized to spend for others.

Now, let’s explore how this data is extracted from the wallet:

```javascript
/*  Code in OpenWallet  */
    // load the wallet        
    var w  = LoadWallet(address);
    
    // if the wallet has a Data field inside (it means that it is an existing wallet)
    if(w.Data !== '') {
    
        // the data, in json format is parsed
        var data = JSON.parse(w.Data);

        // we extract here the balance
        if ('Balance' in data)    { this.Balance = data.Balance;      }
        
        // we extract here the allowances
        if ('Allowances' in data) { this.Allowances = data.Allowances;}
    }
    
    // if the wallet didn't contain any instance of this contract, nothing will be done and the initial
    // values of the contract will be used.    
    
    /*  Code in CloseWallet  */
    
    // we create an object with all the info that we wish to store 
    var dataObject = {
           Balance : this.Balance,      // the wallet balance
        Allowances : this.Allowances    // the allowances
      };
      
      // Convert the data object to a JSON string
      var dataString = JSON.stringify(dataObject);
   
      // Use the SaveWallet function to save the updated wallet
      SaveWallet(this.Address, dataString); 
```

As shown, the process is simple: store the needed information in a JSON string and retrieve it easily. With this, you’re ready to create various smart contracts and explore the world of Circular.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://circular-protocol.gitbook.io/hyper-code-ide-guide/lesson-3-wallet-access/custom-wallet-data.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
