Builder's Guide
  • Welcome to the Builder's Guide to the LND Galaxy!
  • The Lightning Network
    • Overview
    • Payment Channels
      • Lifecycle of a Payment Channel
      • Watchtowers
      • Understanding Sweeping
      • Etymology
    • The Gossip Network
      • Identifying Good Peers on the Lightning Network
    • Pathfinding
      • Finding routes in the Lightning Network
      • Channel Fees
      • Multipath Payments (MPP)
    • Lightning Network Invoices
      • Understanding Lightning Invoices
    • Making Payments
      • The Payment Cycle
      • Timelocks
      • ⭐Hashed Timelock Contract (HTLC)
      • Payment Etymology
      • ⭐What Makes a Good Routing Node
      • Understanding Submarine Swaps
      • Instant Submarine Swaps
    • Liquidity
      • ⭐Understanding Liquidity
      • Managing Liquidity on the Lightning Network
      • Liquidity Management for Lightning Merchants
      • How to Get Inbound Capacity on the Lightning Network
      • Lightning Service Provider
    • L402: Lightning HTTP 402 Protocol
      • Macaroons
      • L402
      • 📋Protocol Specification
      • Implementations and Links
    • Taproot Assets
      • Taproot Assets Protocol
      • Taproot Assets on Lightning
      • Edge Nodes
      • Taproot Assets Trustless Swap
      • FAQ
      • Glossary
  • Lightning Network Tools
    • LND
      • 🛠️Get Started
      • lnd.conf
      • First Steps With LND
      • Wallet Management
      • Sending Payments
      • Atomic Multi-path Payments (AMP)
      • Receiving Payments
      • Unconfirmed Bitcoin Transactions
      • Channel Fees
      • Inbound Channel Fees
      • Macaroons
      • Configuring Watchtowers
      • Pathfinding
      • Blinded Paths
      • Key Import
      • Secure Your Lightning Network Node
      • Configuration of a Routing Node
      • Quick Tor Setup
      • Configuring Tor
      • Enable ‘Neutrino mode’ in Bitcoin Core
      • Send Messages With Keysend
      • Partially Signed Bitcoin Transactions
      • Bulk onchain actions with PSBTs
      • Sweeper
      • Debugging LND
      • Fuzzing LND
      • LND API documentation
      • Channel Acceptor
      • RPC Middleware Interceptor
      • HTLC Interceptor
      • NAT Traversal
      • Recovery: Planning for Failure
      • Migrating LND
      • Disaster recovery
      • Contribute to LND
    • Lightning Terminal
      • What is Lightning Terminal?
      • 🛠️Get litd
      • Run litd
      • Integrating litd
      • Demo: Litd Speed Run
      • Connect to Terminal
      • Recommended Channels
      • Rankings
      • Health Checks
      • Liquidity Report
      • Opening Lightning Network Channels
      • Managing Channel Liquidity
      • Autofees
      • AutoOpen
      • LND Accounts
      • Loop and Lightning Terminal
      • Loop Fees
      • Pool and Lightning Terminal
      • Command Line Interface
      • Troubleshooting
      • Lightning Node Connect: Under the hood
      • LNC Node Package
      • LITD API Documentation
      • Privacy and Security
      • Privacy Policy
      • Terms of Use
    • Loop
      • 🛠️Get Started
      • The Loop CLI
      • Autoloop
      • Static Loop In Addresses
      • Instant Loop Outs
      • Peer with Loop
      • Loop API Documentation
    • Pool
      • Overview
      • Quickstart
      • 🛠️Installation
      • First Steps
      • Accounts
      • Orders and Asks
      • Sidecar Channels
      • Zero-confirmation Channels
      • Channel Leases
      • Batch Execution
      • Account Recovery
      • Pool API Documentation
      • FAQs
    • Taproot Assets
      • Get Started
      • First Steps
      • Taproot Assets Channels
      • Asset Decimal Display
      • Become an Edge Node
      • RFQ
      • Collectibles
      • Universes
      • Asset Loop
      • Debugging Tapd
      • Multisignature
      • Minting Assets With an External Signer
      • Lightning Polar
      • Operational Safety Guidelines
      • Taproot Assets API Documentation
    • Aperture
      • ⚒️Get Aperture
      • LNC Backend
      • LNC Mailbox
      • Pricing
    • Faraday
      • 🛠️Get Started
      • The Faraday CLI
      • Faraday API Documentation
  • LAPPs
    • Guides
      • Use Polar to Build Your First LAPP
        • Setup: Local Cluster with Polar
        • Setup: Run the Completed App
        • Setup: Run the App Without LND
      • Add Features
        • Feature 1: Connect to LND
        • Feature 2: Display Node Alias and Balance
        • Feature 3: Sign and Verify Posts
        • Feature 4: Modify Upvote Action
      • Make Your own LNC-powered Application
    • Next Steps
  • Community Resources
    • Resource List
    • Lightning Bulb 💡
    • Glossary
    • FAQ
Powered by GitBook
On this page
  • Development Environment Setup
  • Import the Pre-Defined Network
  • Play with the Completed Sample App

Was this helpful?

  1. LAPPs
  2. Guides
  3. Use Polar to Build Your First LAPP

Setup: Run the Completed App

PreviousSetup: Local Cluster with PolarNextSetup: Run the App Without LND

Last updated 4 years ago

Was this helpful?

Now that you are familiar with Polar, we are going to build a web application that leverages a pre-defined Polar network as its backend. First, we will ensure your development environment is correctly configured. Next, we will import this pre-defined network. Then, we will run the completed sample app so you can see how it works.

In the next section, we will strip the completed sample app down and rebuild the Lightning integration together.

Development Environment Setup

In order to run the web app locally, first install on your computer. Next, install either from the link, or by opening up a Terminal and running:

npm install -g yarn

After getting both of the requirements installed, you’ll need to clone the builders-guide-sample-app repo from GitHub and install its dependencies. To do this, run the following commands from your open Terminal:

git clone https://github.com/lightninglabs/builders-guide-sample-app.git
cd builders-guide-sample-app
yarn

Import the Pre-Defined Network

With the builders-guide-sample-app repo cloned to your local machine, return to Polar and click the Import Network button at the top of your screen to display the following interface.

Click to browse to your local builders-guide-sample-app folder, and select builders-guide.polar.zip in the resources folder. You should be faced with the below screen.

Press Start to download the requisite docker images and simulate your new regtest Lightning Network.

Play with the Completed Sample App

If you’d like to play with the final app, with Lightning integrated, before diving into the code, follow along here. If you’d rather work your way up to the final app, jump ahead to the next section.

Checkout the final branch and start the app:

git checkout final
yarn dev

You should see the screen above after launching the app.

In order to test out all of the functionality, you’ll need to have the predefined network started according to the instructions above. If you've successfully done so, your Polar instance should look like the screenshot below.

First Window:

  1. In the webapp, click the Connect to LND link in the top navbar

  2. In Polar, navigate to alice's Connect dashboard, and copy the GRPC Host url into the webapp's LND Host field.

  3. Select HEX instead of File Path in the bottom half of the Connect dashboard, and copy that version of TLS Cert into the webapp's TLS Certificate field.

  4. Right click on alice's lnd node, select Launch Terminal, paste in lncli bakemacaroon info:read offchain:read invoices:read invoices:write message:read message:write as instructed by the webapp, copy the output and paste it into the webapp's Macaroon field, and finally click the Submit button.

  5. You will be redirected back to the home screen where you’ll see alice’s name and her channel balance (115,048 sats) in the top navbar.

  6. Click on the Create a Post button.

  7. Enter a Title and Content for the post in the form, then click on the Submit button.

  8. You will be redirected back to the main screen where you'll see the post you just created.

  9. Create a couple more posts if you’d like to by repeating steps 4 & 5.

Second Window:

  1. Notice that the posts you created as alice are also visible in this tab. If not, refresh the page.

  2. Click the Connect to LND link in the top navbar.

  3. In Polar, navigate to carol's Connect dashboard, and copy the GRPC Host url into the webapp's LND Host field.

  4. Select HEX instead of File Path in the bottom half of the Connect dashboard, and copy that version of TLS Cert into the webapp's TLS Certificate field.

  5. Right click on carol's lnd node, select Launch Terminal, paste in lncli bakemacaroon info:read offchain:read invoices:read invoices:write message:read message:write as instructed by the webapp, copy the output and paste it into the webapp's Macaroon field, and finally click the Submit button.

  6. You will be redirected back to the home screen where you’ll see carol’s name and her channel balance (125,000 sats) in the top navbar.

  7. On the first post created, click the Verify Signature button

  8. The button should disappear and a green verified badge should appear in both tabs.

  9. Click on the Upvote button for the first post.

  10. A popup will appear with a Lightning payment request string generated by alice for her post. Copy this to your clipboard.

  11. In Polar, right click on the carol node and choose the Pay Invoice option.

  12. Paste the payment request string into the BOLT 11 Invoice field in Polar, then click the Pay Invoice button.

  13. Switch back to the two browser tabs and notice the post now displays 1 vote under the content.

  14. In the first window, alice’s balance in the navbar has increased by 100 sats to 116,048 sats, and in the second window, carol's balance in the navbar has decreased by 101 sats to 124,899 sats.

Now that you’ve seen all of the amazing features our Lightning App has, dive into the code in the next section to learn how this app was built.

Open your browser to if it doesn’t open automatically.

The app requires multiple users to explore all of its functionality. Open a second window side by side with the first one, and navigate to . Feel free to poke around the app yourself. Here are some guided steps you can perform to see all of the features.

http://localhost:3000
http://localhost:3000
NodeJS v12.x
Yarn v1.x
Import Interface
Imported Builder's Guide Network
Completed Sample App Interface
Started Builder's Guide Network