Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <script src="https://cdn.jsdelivr.net/npm/gun/gun.js"></script>
<script src="https://cdn.jsdelivr.net/npm/gun/sea.js"></script>
<script src="https://cdn.jsdelivr.net/npm/tydids-p2p/TydidsP2P.min.js">
  <!--
  addMaster(): Creates a decentralized Key / Value storage(JSON).
  If your browser does not have an Identity, a new one will be created => createInstance()
  If you do not have a DID - Presentation(place where JSON is stored) a new one will be created => connectDIDPresentation()
  Values get stored using setJSON()
  On another computer / system:
    use appSlave() with the address of first instance(0x...) to retrieve values.
  Alternative on a CLI(with Node JS):
    npm install - g tydids - p2p
  tydids--createPrivateKey - w - x
  tydids - p < ADDRESS of first instance > -x
  -->
              
            
!

CSS

              
                
              
            
!

JS

              
                const gun = Gun({ peers: ["https://webrtc.tydids.com/gun"] });

const createInstance = async function () {
  let privateKey = window.localStorage.getItem("privateKey");
  if (typeof privateKey == "undefined" || privateKey == null) {
    let tmpwallet = TydidsP2P.ethers.Wallet.createRandom();
    window.localStorage.setItem("privateKey", tmpwallet.privateKey);
    privateKey = tmpwallet.privateKey;
  }
  window.ssi = await TydidsP2P.ssi(privateKey, gun);
};

const connectDIDPresentation = async function (address) {
  if (typeof address == "undefined" || address == null) {
    address = window.localStorage.getItem("defaultDID");
    if (typeof address == "undefined" || address == null) {
      let did = await window.ssi.createManagedPresentation();
      window.localStorage.setItem("defaultDID", did.address);
      address = did.address;
    }
  }
  return address;
};

const setJSON = async function (address, obj) {
  return await window.ssi.updateVP(address, obj);
};

const getJSON = async function (address) {
  return await window.ssi.retrieveVP(address);
};

const appMaster = async function () {
  await createInstance();
  const addressPresentation = await connectDIDPresentation();
  await setJSON(addressPresentation, {
    time: new Date().toLocaleString(),
    random: Math.random()
  });
  console.log(
    "Storage",
    addressPresentation,
    await getJSON(addressPresentation)
  );
};

const appSlave = async function (addressPresentation) {
  await createInstance();
  console.log(
    "Storage",
    addressPresentation,
    await getJSON(addressPresentation)
  );
};

appMaster();
// appSlave('0x8468084cf5274CBCc529D3bC404A44bF9b3Df76D'); // Test in second browser with your address

              
            
!
999px

Console