Pen Settings



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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


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


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.


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.


                ### Interaction

<script src=""></script>
<script src=""></script>

    <select id="network">
      <option value="test">Test</option>
      <option value="public">Public</option>
    <textarea id="xdr" rows="5" placeholder="Public Key or Federated Address"></textarea>
    <input id="sep7" type="button" value="Sign using SEP7">
    <input id="cosmicLink" type="button" value="Sign using">
    <pre id="cosmiclink_description"></pre>


### Description

This pen makes use of `cosmic-lib` to generate SEP7 and CosmicLink requests from a transaction XDR. This is to let the user sign a transaction using her own wallet.

### Concepts

- [SEP7]( a protocol that passes transaction requests to wallets.
- [CosmicLink]( another protocol that passes transaction requests from applications to wallets.
- [XDR]( The binary format Stellar ledger uses.

### Keypoints

- For SEP7 to work, you need to have registered a SEP7 handler.
- On desktop environments, you can register the [cosmic-lib demo interface]( as your SEP7 handler.
- The code of this pen shows how to authenticate the SEP7 request `origin_domain`, but this part is commented out as it is not meant to be done client-side.
- You can use almost the same code to generate SEP7 & CosmicLink requests from a StellarSdk _Transaction_ or a JSON.
- The only difference is that you don't need to provide `network` to `new CosmicLink(tx|json)`.

### Challenges

- **easy/** Edit this pen to add support for the **#callback** parameter in the form. _Hint:_ you can set it the same way than **#network**.
- **hard/** Edit this pen to add support for arbitrary **#network** passphrases. You'll offer the user to enter an **#horizon** URL for custom networks.

_Give it a try by editing the code, and be the first to post a solution on GalacticTalk!_

### Documentation

- [Stellar networks](
- [CosmicLink documentation](

### Social

- [Discuss that pen on GalacticTalk](




                // $ npm install cosmic-lib
// const cosmicLib = require("cosmic-lib")
const { CosmicLink } = cosmicLib

const $ = document.querySelector.bind(document)

/* Configuration */
const network = "test"

// Default CosmicLink handler. = ""

/* Logic */
function xdrToCosmicLink (xdr, network) {
  const cosmicLink = new CosmicLink(xdr, { network })
  // cosmicLink.signSep7(domain, keypair)
  return cosmicLink

/* Interface */
function updateButtons () {
  const xdr = $("#xdr").value
  const network = $("#network").value
  const cosmicLink = xdrToCosmicLink(xdr, network)
  $("#sep7").onclick = () => open(cosmicLink.sep7)
  $("#cosmicLink").onclick = () => open(cosmicLink.uri)

/* Events */
$("#network").oninput = updateButtons
$("#xdr").oninput = updateButtons

/* Initialization */
$("#xdr").value = xdr