Bounties Documentation

Getting Started

Note: This documentation is in an alpha state - please help us improve it by clicking "Suggest Edits" in the upper right corner!

This is the Bounties SDK documentation. To go to the Bounties API documentation, click here.

The Bounties SDK provides redux-saga wrappers for StandardBounties smart contract calls and for requests to our platform's API endpoints. Additionally, it provides several general purpose modules such as authentication and client which can be dropped into any dapp to manage wallet access and session authentication.

Installation

The library is available as an NPM package, just run the command below to add it to an existing project. If you're starting a new project, consider our starter kit which already has the boilerplate set up.

yarn add @bounties-network/modules

After the module has been added, you'll just need to import and configure it. For more configuration options, see configuration in the reference section.

import Client from '@bounties-network/modules'
  
Client.init({
  "platforms": "bounties-network",
  "postingPlatform": "bounties-network",
  "postingSchema": "standardSchema",
  "postingSchemaVersion": "0.1",
  "categoryPlatform": "main",
  "networkName": "staging.bounties.network",
  "url": {
    "mainNet": "https://staging.api.bounties.network",
    "rinkeby": "https://rinkebystaging.api.bounties.network"
  },
  "requiredNetwork": "rinkeby",
  "deployments": {
    "standardBountiesAddress": {
      "rinkeby": "0xdd1636b88e9071507e859e61991ed4be6647f420"
    }
  }
})

Since the library also relies heavily on redux and redux-saga, it is necessary to import the reducer and sagas and integrate them with the main project's reducer / saga watcher.

import createSagaMiddleware from 'redux-saga'
import { createStore, applyMiddleware } from 'redux'
import { reducers, sagaWatchers} from '@bounties-network/modules'

const store = createStore(
  reducers,
  composeEnhancers(applyMiddleware(createSagaMiddleware()))
)

[...sagaWatchers].map(saga => sagaMiddleware.run(saga, store.dispatch))

Preface

This library is an alpha release of the Bounties Network library. We are still rapidly developing on all fronts. If you encounter an issue, please let us know on GitHub. If you are interested in contributing, checkout out our contribution guide to see how to get involved (and potentially paid).

Additionally, this library offers raw access to a set of reducers and saga wrapper to Bounties Network related objects. If you're unfamiliar with Redux or Redux-Saga, it is highly recommended to first understand the basics of those tools. The rest of the documentation will assume basic understanding of those concepts.

Using the Library

The module is roughly broken down into a few different importable objects:

  • actions : all dispatchable actions
  • selectors : all selectors
  • sagas : all exported saga functions

Each object will have a key-value pair for every submodule. For example, if you wanted to dispatch an a LOAD_BOUNTIES action you would need to do the following:

import { actions } from '@bounties-network/modules'
  
const loadBounties = dispatch => dispatch(actions.bounties.loadBounties())

Once an action has been dispatched and the sagas complete executing, the data will be available in the store. The best way to access it is via the selectors. To access the bounties that were loaded as a result of the last code snippet, just add the following code:

import { selectors } from '@bounties-network/modules'
  
const getBounties = state => selectors.bounties.bountiesSelector

In practice, the above code snippets would most likely be integrated into the mapDispatchToProps and mapStateToProps portion of your React application.

Updated about a year ago

Getting Started


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.