Skip to main content

Class: TokenLocking

Constructors​

new TokenLocking()​

new TokenLocking(colonyNetwork, address): TokenLocking

Parameters​

colonyNetwork​

ColonyNetwork

address​

string

Returns​

TokenLocking

Properties​

address​

address: string

Methods​

deposit()​

deposit(tokenAddress, amount): MetaTxCreator\<TokenLockingClient, "deposit(address,uint256,bool)", { amount: BigNumber; token: string; user: string; }, MetadataType>

Deposit amount of the wallet owners holdings of the Colony's native token into the Colony.

In order for the wallet owner to stake tokens, that amount has to be approved and deposited into the Colony first. In the dapp the process is called "Activation" of a certain amount of the Colony's native token. The wallet must hold at least the amount of the token that will be deposited.

Parameters​

tokenAddress​

string

Token to be deposited

amount​

BigNumberish

Amount of the token to be deposited

Returns​

MetaTxCreator\<TokenLockingClient, "deposit(address,uint256,bool)", { amount: BigNumber; token: string; user: string; }, MetadataType>

A transaction creator

Event data​

PropertyTypeDescription
tokenstringThe address of the Colony's native token
userstringThe address that deposited the tokens from their wallet
amountBigNumberAmount that was deposited

Example​

import { w } from '@colony/sdk';

// Immediately executing async function
(async function() {
const token = await colony.getToken();
// Approve 100 tokens for the Colony Network to activate
await token.approve(w`100`).tx().mined();
// Deposit the tokens
await colonyNetwork.locking.deposit(token.address, w`100`).tx().mined();
})();

getUserApproval()​

getUserApproval(tokenAddress, user, obligator): Promise\<BigNumber>

Get the wallet owner's approved balance of the Colony's native token for an obliator (i.e. an extension)

This method will show the accumulated amount that was approved using the ColonyToken.approve method

Parameters​

tokenAddress​

string

Token to check

user​

string

The wallet address that we want to check the approved amount of

obligator​

string

The address that has been approved to obligate the funds.

Returns​

Promise\<BigNumber>

The currently approved balance of the Colony's native token for the obligator


getUserDeposit()​

getUserDeposit(tokenAddress, user): Promise\<BigNumber>

Get the wallet owner's deposited and locked balance of the Colony's native token.

This method will show the accumulated amount that was deposited using the deposit method

Parameters​

tokenAddress​

string

Token to check

user​

string

The wallet address that we want to check the deposited amount of

Returns​

Promise\<BigNumber>

The currently deposited balance of the Colony's native token


withdraw()​

withdraw(tokenAddress, amount): MetaTxCreator\<TokenLockingClient, "withdraw(address,uint256,bool)", { amount: BigNumber; token: string; user: string; }, MetadataType>

Withdraw amount of the wallet owners holdings of the Colony's native token from the Colony.

Does the opposite of deposit and frees the deposited tokens back to the wallet address.

Parameters​

tokenAddress​

string

Token to be withdrawn

amount​

BigNumberish

Amount of the token to be withdrawn

Returns​

MetaTxCreator\<TokenLockingClient, "withdraw(address,uint256,bool)", { amount: BigNumber; token: string; user: string; }, MetadataType>

A transaction creator

Event data​

PropertyTypeDescription
tokenstringThe address of the Colony's native token
userstringThe address that withdrew the tokens from their wallet
amountBigNumberAmount that was withdrawn

Example​

import { w } from '@colony/sdk';

// Immediately executing async function
(async function() {
const token = await colony.getToken();
// Withdraw 100 tokens that were previously deposited
await colonyNetwork.locking.withdraw(token.address, w`100`).tx().mined();
})();