colonyJS icon indicating copy to clipboard operation
colonyJS copied to clipboard

🎪 Colony TypeScript libraries

colonyJS

colonyJS is a JavaScript library with a simple and predictable interface for application-layer integrations with the colonyNetwork smart contracts. To learn more about Colony, you can visit colony.io or read the White Paper.

Documentation

The API reference is automatically generated using TypeDoc and can be found here. You should check out the getColonyNetworkClient function in ColonyNetworkClient and the docs for the extended colony contracts clients/Colony/ColonyClientVX.

Get Started

import { providers, utils, Wallet } from 'ethers';
import { getColonyNetworkClient, Id, Network, Tokens } from '@colony/colony-js';

const { formatEther } = utils;

const provider = new providers.JsonRpcProvider('https://xdai.colony.io/rpc2/');

const start = async () => {
  // Get a wallet instance
  const wallet = new Wallet(
    // This is a random private key (don't use this one for anything else and _definitely_ do not send valuables to the corresponding address)
    '0x0355596cdb5e5242ad082c4fe3f8bbe48c9dba843fe1f99dd8272f487e70efae',
    provider,
  );

  // Check out the logs to see the wallet address
  console.log('Wallet Address:', wallet.address);

  // Get a network client instance for Gnosis Chain
  const networkClient = await getColonyNetworkClient(
    Network.Gnosis,
    wallet,
  );

  // Let's connect to the Meta Colony
  const metaColonyClient = await networkClient.getMetaColonyClient()
  // And check out it's CLNY funding
  const funding = await metaColonyClient.getFundingPotBalance(Id.RootPot, Tokens.Gnosis.CLNY);
  // We can also see its address
  const { address } = metaColonyClient;
  console.info(`${formatEther(funding)} CLNY in root domain of MetaColony with address: ${address}`);
};

start();

Too complicated? Need more guidance?

Try colonySDK.

Contributing

We welcome all contributions to colonyJS! See Contributing for more information.

Development

Local development

Using just npm you can link the built colonyJS files to your Dapp when developing new features in colonyJS while trying them out immediately in your dev-environment.

To do that:

  1. Make sure you are using the exact same node version in colonyJS and the Dapp. Use nvm if possible

  2. Update the required submodules:

git submodule update --init --recursive
  1. Build colonyJS. In the colonyJS directory do:
npm run build
  1. Create an npm link in the colonyJS directory:
npm link
  1. Link to it in the Dapp directory:
npm link @colony/colony-js
  1. Then do a regular install in the Dapp directory:
npm install

To overwrite the link again just specify a version that exists on npm:

npm install @colony/colony-js@^5.0.6

If that doesn't remove it, just remove the folder in node_modules

To release a new version

colonyJS 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.

To upgrade to a new colonyNetwork version

Take a look at this guide.

License

GPL-3.0