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. 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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                ### Interaction

<form action="https://cosmic.link">
  
  <input name="type" type="hidden" value="payment">
  
  <fieldset><legend>#network</legend>
    <select name="network">
      <option value="test">Testnet</option>
      <option value="public">Public</option>
    </select>
  </fieldset>
  
  <fieldset><legend>#memo</legend>
    <input name="memo" type="text" placeholder="28 characters max" required>
  </fieldset>
  
  <fieldset><legend>#destination</legend>
    <input name="destination" type="text" placeholder="Public key or federated address" required>
  </fieldset>
  
  <fieldset><legend>#amount</legend>
    <input name="amount" type="number" min="0" required>
  </fieldset>

  <fieldset><legend>#submit</legend>
    <input id="submit" type="submit" value="Submit">
  </fieldset>
  
</form>
  

### Description

This pen shows how to leverage the CosmicLink format to pass a transfer request from a simple HTML form.


### Keypoints

- Because it doesn't need any library, this pen is the lightest transfer form ever made!
- The HTML form builds a CosmicLink query that is passed to the Cosmic.link website.
- CosmicLink queries syntax has been derived from `js-stellar-sdk` operations syntax.
- It is possible to create multi-operation transactions using the syntax `?type=transaction&{...metaFields|txFields}&operation={type1}&{...op1Parameters}...&operation={typeN}&{...opNParameters}`
- By leveraging the multi-operation syntax and hidden inputs, it is possible to create advanced transaction templates.

### Challenges

- **Easy/** Transform the HTML form into a donation form, that let the user send any amount to an address of your choice.
- **Hard/** Edit the form into one that let the user open a trustline for a selection of assets.

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


### Documentation

- <a href="https://cosmic.plus/#view:js-cosmic-lib/web/doc/tutorial-20-cheatsheet-query.html" target="_blank">CosmicQueries cheatsheet</a>
- <a href="https://stellar.github.io/js-stellar-sdk/Operation.html" target="_blank">StellarSdk Operations specification</a>

### Social

- [Discuss that pen on GalacticTalk](https://galactictalk.org/d/2122-pen-of-the-week-html-only-transfer-request-form)
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console