3

No need to elaborate too much. I'm working with some contracts on the browser IDE and I want to make sure they are properly stored. I can access them every time I connect with my laptop but I wonder what can happen if I change laptop/browser and the like

6

They're stored in the browser's Local Storage (part of the Web Storage API), which is supported by all of the main browsers. That means the files are stored on your laptop, not in the cloud.

Specifically, each .sol file you have open in Remix will be stored as a key:value pair. The key is the name of the file, the value is the contents (i.e. the Solidity code).

For example, in Chrome, if you open the Chrome Developer Tools by pressing F12 on any given page, then open the Application tab, then under Local Storage you'll find a list of the key:value pairs which are stored for that page.

For the purpose of backing up the data manually, the key:values are stored as a database under a user's profile data, for example %LocalAppData%\Google\Chrome\User Data\Default\Local Storage.

The above examples are for Chrome, and that example path is for Windows. Adjust for browser and OS accordingly.


I can access them every time I connect with my laptop but I wonder what can happen if I change laptop/browser and the like

If you change laptop you will need to move the local storage data to the new laptop. Chrome will do this for you by syncing your profile data to the Google cloud. You will have to check other browsers' behaviours.

Different browsers store local storage data in different places, so you will need to manually convert or copy between them.

4

As mentioned before Remix IDE stores .sol files content in localStorage.


View

Open DevTools in your browser and type in console

localStorage

Backup

You can easily export content of the localStorage to your clipboard (as a string)

copy(JSON.stringify(JSON.stringify(localStorage))); // Yes, double stringify

Restore

var obj = JSON.parse(/*paste stringified localStorage here*/); // Yes, single parse
Object.keys(obj).forEach(function (k) {
    localStorage.setItem(k, obj[k]);
});

and reload page.

4

I've upgraded a part of codes from @Richard Horrocks.

First, just copy to clipboard this 'localStorage'

> copy(localStorage); 

You can check beautifully json codes.

and if you restore your sol files, you can this after pasting localStorage code to input objRemix variable.

var objRemix = {}

Object.keys(objRemix).forEach(function (k) {
  localStorage.setItem(k, objRemix[k]);
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.