Giter Site home page Giter Site logo

abuchtela / colonysdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joincolony/colonysdk

2.0 0.0 0.0 4.45 MB

:rocket: Get started with Colony quickly

Home Page: https://colony.io/

License: GNU General Public License v3.0

Shell 0.33% JavaScript 0.20% TypeScript 99.47%

colonysdk's Introduction

๐Ÿš€ The Colony SDK. Get started with Colony quickly

Discord

Colony SDK

The Colony SDK is under heavy development by the community and will be an easy-to-use interface for the Colony Network contracts, providing simple functions that hide the dark magic going on under the hood of ColonyJS. It should cover the most common use cases and is constantly updated with new features.

Colony SDK also includes a variety of examples to get you up and building with Colony in no time!

Quickstart

// index.js
import { providers } from 'ethers';
import { ColonyNetwork, toEth } from '@colony/sdk';

// If MetaMask is installed there will be an `ethereum` object on the `window`
// NOTE: Make sure MetaMask is connected to Gnosis chain (see https://www.xdaichain.com/for-users/wallets/metamask/metamask-setup)
const provider = new providers.Web3Provider(window.ethereum);

// Get the Colony's XDAI funding in the ROOT pot (id 1)
const start = async () => {
  // This will try to connect the page to MetaMask
  await provider.send('eth_requestAccounts', []);
  // Create a new connection to the Colony Network contracts using the MetaMask "wallet"
  const colonyNetwork = new ColonyNetwork(provider.getSigner());
  // Connect to the MetaColony (this could be replaced with your own colony using `colonyNetwork.getColony(COLONY_ADDRESS)`)
  const metaColony = await colonyNetwork.getMetaColony();
  // Get the CLNY funding for the MetaColony (CLNY is it's native token)
  const funding = await metaColony.getBalance();
  // The funding will be in wei (x * 10^18), so we format into a readable string using the `toEth` function
  alert('MetaColony balance is ' + toEth(funding) + ' CLNY');
};

start();

For more info, see the docs.

Running the examples

First, clone this repo:

git clone https://github.com/JoinColony/colonySDK.git

Then install all the required dependencies (this will install ethers.js and colonyJS as well as some required development dependencies):

npm install

Then you can run the examples:

Node.js

npm run examples:node

Browser (vanilla JS example)

npm run examples:browser

Some notes

These examples will run on Gnosis chain. If you'd like to make transactions, you will need some XDAI. Reach out to us in our Discord if you're having trouble starting out.

Development

Prerequisites

  • Node >=16.0.0

You may find it helpful to use Node Version Manager (nvm) to manage Node versions.

Creating a new release

colonySDK is using release-it to create new releases. To create and publish a new release, commit your changes, then execute

npm run release -- SEMVER_TAG # SEMVER_TAG is major, minor, patch

If you don't supply a GITHUB_TOKEN environment variable, release-it will open a browser window and pre-populate the corresponding release input fields for you.

Frequent commits and descriptive commit messages will help when release-it tries to autogenerate the changelog.

Contribute

Are you interested in contributing? Check out the following document for more information:

colonysdk's People

Contributors

0xjjpa avatar chmanie avatar dependabot[bot] avatar gichiba avatar gtarsia avatar igorline avatar jameslefrere avatar ryanchristo avatar sprusr avatar

Stargazers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.