/aragon.js

A JavaScript library for interacting with Aragon

Primary LanguageJavaScriptGNU Affero General Public License v3.0AGPL-3.0

API stability NPM version Build Status Test Coverage Downloads Standard

Basic Overview

The layer between Aragon Core and the Aragon web- and desktop application. Use it to build third-party apps for Aragon, or to roll your own front-end.

Install

npm i @aragon/client

Quick Start

const Aragon = require('@aragon/client')

// Set up app
const app = new Aragon()

// Set app identifier
// Just an example, should be more descriptive (e.g. for our token manager, we use the ticker of the token it manages)
app.identify(Math.random())

// Listen to events and build app state
const state$ = app.store((state, event) => {
  // Initial state
  if (state === null) state = 0
  
  // Build state
  if (event.event === 'Decrement') {
    state--
    
    // Send notification
    app.notify('Counter decremented', `The counter was decremented to ${state}`)
  }
  if (event.event === 'Increment') {
    state++
    app.notify('Counter incremented', `The counter was incremented to ${state}`)
  }
  
  return state
})

// Log out the state
state$.subscribe(console.log)

// Send an intent to the wrapper
app.increment().subscribe(
  (txHash) => console.log(`Success! Incremented in tx ${txHash}`),
  (err) => console.log(`Could not increment: ${err}`)
)

Documentation

For wrappers, see here.

For apps, see here.

Contributing

Please take a look at our contributing guidelines if you're interested in helping!