Skip to content

Latest commit

 

History

History

sdk

🚀 The development kit to build on top of Colony

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 covers everything the dApp can do, so you'll be able to run your DAO entirely programmatically 👩‍💻

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

Quickstart

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 ArbitrumOne chain (use https://app.colony.io/public-rpc or see https://chainlist.org/chain/42161)
const provider = new providers.Web3Provider(window.ethereum);

// Get the MetaColony's CLNY funding in the root team (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();

Documentation

📑 Click here for docs!

Running the examples

We are using the pnpm version manager for this project. Please make sure to have a current version of it installed on your system.

First, clone this repo:

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

Go to the sdk package directory:

cd colonyJS/packages/sdk

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

pnpm install

Then you can run the examples:

Node.js

pnpm run examples:node

Browser (vanilla JS example)

pnpm run examples:browser

Some notes

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

Development

Prerequisites

  • Node >= 16
  • pnpm >= 8

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

License

GPL-3.0