ColonyNetworkClient

The ColonyNetworkClient is a standard interface for interactions with functions and events described in IColonyNetwork.sol.

These interactions are generally concerned with the colony network as a whole, rather than at the colony level. This includes operations like getting a count of all colonies on the network, querying for information about a parent skillId, or deposits/withdrawals of staked CLNY for use in the reputation system.

You can learn more about the solidity implementation from the Colony Network Docs.

For interactions within a particular colony, see the ColonyClient docs.

Creating a new instance

Assuming you're inside an async function:

const networkClient = new ColonyNetworkClient({ adapter });
await networkClient.init();

Instance methods

All instance methods return promises.

createToken({ name, symbol, decimals })

Deploys a new ERC20 compatible token contract for you to use with your Colony. You can also use your own token when creating a Colony.

Arguments

ArgumentTypeDescription
namestringName of the token to create (e.g. Cool Colony Token)
symbolstringSymbol of the token to create (e.g. CCT)
decimalsstringDecimals of your token (default: 18).

Returns

Promise<Address> The address of the newly deployed token contract

getColonyClientByAddress(contractAddress)

Returns an initialized ColonyClient for the contract at address contractAddress

Arguments

ArgumentTypeDescription
contractAddressAdressAddress of a deployed Colony contract

Returns

Promise<ColonyClient>. An instance of a ColonyClient associated with the given Colony contract

getColonyClient(id)

Returns an initialized ColonyClient for the specified id of a deployed colony contract.

Arguments

ArgumentTypeDescription
keystringName of the Colony to get
idnumberInteger number of the Colony

Returns

Promise<ColonyClient>. An instance of a ColonyClient associated with the given Colony contract

getColonyAddress(id)

Get the address of a Colony for the specified id of a deployed colony contract.

Arguments

ArgumentTypeDescription
keystringName of the Colony to get
idnumberInteger number of the Colony

Returns

Promise<Address>. The address of the given Colony contract

getMetaColonyClient()

Gets the Meta Colony as an initialized ColonyClient

Returns

Promise<ColonyClient>. An instance of a ColonyClient associated with the MetaColony contract

Callers

All callers return promises which resolve to an object containing the given return values. For a reference please check here.

getColony.call({ id })

Returns the address of a colony when given the ID

Arguments

ArgumentTypeDescription
idnumberInteger colony ID

Returns

A promise which resolves to an object containing the following properties:

Return valueTypeDescription
addressAddressAddress of the colony contract

getMetaColonyAddress.call()

Returns the address of the Meta Colony

Returns

A promise which resolves to an object containing the following properties:

Return valueTypeDescription
addressAddressAddress of the Meta Colony contract

getColonyCount.call()

Returns the number of colonies created on the Colony Network, i.e. the colonyId of the most recently created colony.

Returns

A promise which resolves to an object containing the following properties:

Return valueTypeDescription
countnumbercolonyId of the most recently created colony

getColonyVersionResolver.call({ version })

Given a version of the colony contract, returns the address of the corresponding Resolver contract

Arguments

ArgumentTypeDescription
versionnumberThe Colony contract version

Returns

A promise which resolves to an object containing the following properties:

Return valueTypeDescription
addressAddressAddress of the Resolver contract

getCurrentColonyVersion.call()

Returns the latest Colony contract version. This is the version used to create all new colonies.

Returns

A promise which resolves to an object containing the following properties:

Return valueTypeDescription
versionnumberThe current / latest Colony contract version

getParentSkillId.call({ skillId, parentSkillIndex })

Given the id of a particular skill, returns the skill's parent skill id

Arguments

ArgumentTypeDescription
skillIdnumberId of the skill
parentSkillIndexnumberIndex of the skill.parents array to get

Returns

A promise which resolves to an object containing the following properties:

Return valueTypeDescription
parentSkillIdnumberId of the parent skill

getReputationUpdateLogEntry.call({ id })

Gets the ReputationLogEntry at a specified index for either ther currently active or inactive reputation update log

Arguments

ArgumentTypeDescription
idnumberThe reputation log members array index of the entry to get

Returns

A promise which resolves to an object containing the following properties:

Return valueTypeDescription
amountBigNumberamount
colonyAddressAddress of the colony
nPreviousUpdatesnumbernumber of previous updates
nUpdatesnumbernumber of updates
skillIdnumberskill Id
userAddressuser address

getReputationUpdateLogLength.call()

Gets the length of the reputation update log for either the current active or inactive log

Returns

A promise which resolves to an object containing the following properties:

Return valueTypeDescription
countnumberLength of Reputation update log array

getSkill.call({ skillId })

Returns the number of parent and child skills associated with the provided skill

Arguments

ArgumentTypeDescription
skillIdnumberskillId to be checked

Returns

A promise which resolves to an object containing the following properties:

Return valueTypeDescription
nParentsnumberNumber of parent skills
nChildrennumberNumber of child skills

getSkillCount.call()

Get the total number of skills in the network (both global and local skills)

Returns

A promise which resolves to an object containing the following properties:

Return valueTypeDescription
countnumberThe number of skills on the network

getStakedBalance.call({ user })

Get the amount of staked CLNY tokens for a given user address

Arguments

ArgumentTypeDescription
userAddressAddress of the user

Returns

A promise which resolves to an object containing the following properties:

Return valueTypeDescription
balanceBigNumberAmount of staked CLNY

Senders

All senders return an instance of a ContractResponse. Every send() method takes an options object as the second argument. For a reference please check here.

createColony.send({ tokenAddress }, options)

Creates a new colony on the network.

Arguments

ArgumentTypeDescription
tokenAddressAddressToken to import. Note: the ownership of the token contract must be transferred to the newly-created Colony.

Returns

An instance of a ContractResponse which will eventually receive the following event data:

Event dataTypeDescription
colonyIdnumberID of the newly-created Colony
colonyAddressAddressAddress of the newly-created Colony

deposit.send({ amount }, options)

Allow a reputation miner to stake an amount of CLNY tokens, which is required before they can submit a new reputation root hash via ReputationMiningCycle.submitNewHash

Arguments

ArgumentTypeDescription
amountBigNumberAmount of CLNY to stake

Returns

An instance of a ContractResponse

startTokenAuction.send({ tokenAddress }, options)

Create and start a new Dutch Auction for the entire amount of a specified token owned by the Colony Network

Arguments

ArgumentTypeDescription
tokenAddressAddressAddress of the token held by the network to be auctioned

Returns

An instance of a ContractResponse which will eventually receive the following event data:

Event dataTypeDescription
auctionstringThe address of the auction contract
tokenAddressThe address of the token being auctioned
quantitynumberThe amount of available tokens for auction

upgradeColony.send({ id, newVersion }, options)

Upgrades a colony to a new Colony contract version.

Arguments

ArgumentTypeDescription
idnumberColony ID to be upgraded
newVersionnumberThe target version for the upgrade

Returns

An instance of a ContractResponse

withdraw.send({ amount }, options)

Allow a user who has staked CLNY to withdraw their stake

Arguments

ArgumentTypeDescription
amountBigNumberAmount of CLNY to withdraw from stake

Returns

An instance of a ContractResponse