Home

Awesome

<br /><br />

<div align="center"> <img height="150" style="object-fit: contain" src="https://substrate.io/img/substrate_og.png" alt="substrate connect"> <h4 align="center"> NPM packages that offers an innovative way to interact with <a href="https://substrate.dev/">Substrate</a>-based blockchains directly in your browser.</h4> </div>

<br /><br />

Table of contents

Introduction

Substrate Connect provides a groundbreaking method to engage with Substrate-based blockchains directly in your browser, eliminating the need for an RPC server. By utilizing the smoldot WASM light client, it ensures a secure and efficient connection to the blockchain network without reliance on specific third parties.

Write Secure and Effective dApps with the Polkadot Network

The aim of this repository is to offer NPM packages that can be used to:

We also provide example projects using the above packages, including:

Additional Resources

Why Embed a Light Client in Browser Extensions?

Embedding a light client in browser extensions offers several advantages:

Comprehensive API Documentation

For detailed API usage, refer to the Substrate Connect API documentation.

Repository Structure

Packages

The core implementations of @subtrate/connect and @substrate/discovery, and some auxiliary packages.

Showcase Projects

Showcase full implementations of @substrate/connect and @substrate/discovery for a Wallet, Extension or Generic usage.

Examples

dApp and Extensions example implementations of @substrate/connect and @substrate/discovery.

Development

This repository utilizes pnpm workspaces and corepack, ensuring the correct version of pnpm is used. For contributions, please review our contributing guidelines to understand our workflow and how to smoothly integrate your contributions to the project.

Getting Started

Follow these steps to install everything and launch a demo if you're hacking on this repository:

  1. Install Prerequisites (tested with the following versions):

    • Node.js (node) v20.9.0
    • pnpm 9.0.6 (npm install -g pnpm)
    • corepack 0.20.0 (bundled with recent Node.js versions)
  2. Clone the Repository:

    • git clone https://github.com/paritytech/substrate-connect.git
    • Navigate to the repository root: cd substrate-connect
  3. Install Dependencies:

    • corepack pnpm install
  4. Run the Extension in Development Mode:

    • In terminal A: cd projects/extension && corepack pnpm dev
  5. Launch the Extension:

    • In terminal B: cd projects/extension && corepack pnpm start
    • This opens a Chrome browser window with the extension pre-loaded. Ensure the extension is running.
  6. Run the Demo Application:

    • In terminal C: cd projects/demo && corepack pnpm dev
    • Navigate to the URL logged in the Chrome browser opened in step 5. You should see the extension activate and the demo app log the latest blocks.

Cleanup Commands

To clean up all build artifacts in workspaces in the repository:

corepack pnpm clean

To clean up all build artifacts and dependencies in workspaces in the repository:

corepack pnpm deep-clean

Releasing

For releasing a new version of the extension, follow the steps outlined in the release doc.

Useful Links