TokenLockingClient

The TokenLockingClient is a standard interface for interactions with methods and events described in ITokenLocking.sol. These interactions are generally concerned token locking, such as locking and unlocking tokens.

See Clients for more information about initializing TokenLockingClient.

See ContractClient for more information about the ContractClient superclass.

Callers

getTotalLockCount

Get the total number of locked tokens.

await tokenLockingClient.getTotalLockCount.call({
  token,
});

Input

NameTypeDescription
tokenaddress (0x0 included)The address of the token contract (an empty address if Ether).

Response

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

NameTypeDescription
countnumberThe total number of locked tokens in the colony.

Contract Information

Contract: TokenLocking.sol

Interface: ITokenLocking.sol

getUserLock

Get the total number of locked tokens for a given user.

await tokenLockingClient.getUserLock.call({
  token,
  user,
});

Input

NameTypeDescription
tokenaddress (0x0 included)The address of the token contract (an empty address if Ether).
useraddressThe address of the user.

Response

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

NameTypeDescription
countbig numberThe total number of locked tokens.

Contract Information

Contract: TokenLocking.sol

Interface: ITokenLocking.sol

Senders

deposit

Deposit tokens. This function only be called if the tokens that the user is attempting to deposit are not locked and if the user has allowed the token locking contract to transfer the tokens.

await tokenLockingClient.deposit.send({
  token,
  amount,
}, options);

Input

NameTypeDescription
tokenaddress (0x0 included)The address of the token contract (an empty address if Ether).
amountbig numberThe amount of tokens that will be deposited.

Options

See Sender for more information about options.

Response

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

NameTypeDescription
tokenaddress (0x0 included)The address of the token contract receiving the deposit.
useraddressThe address of the user that deposited tokens.
amountbig numberThe amount of tokens that were deposited.
timestampdateThe timestamp when the tokens were deposited.
UserTokenDepositedobjectContains the data defined in UserTokenDeposited

See Sender for more information about ContractResponse.

Contract Information

Contract: TokenLocking.sol

Interface: ITokenLocking.sol

lockToken

Lock all tokens for a given token contract.

await tokenLockingClient.lockToken.send({
  token,
}, options);

Input

NameTypeDescription
tokenaddress (0x0 included)The address of the token contract (an empty address if Ether).

Options

See Sender for more information about options.

Response

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

NameTypeDescription
tokenaddress (0x0 included)The address of the token contract that was locked.
lockCountbig numberThe address of the token contract that was assigned.
TokenLockedobjectContains the data defined in TokenLocked

See Sender for more information about ContractResponse.

Contract Information

Contract: TokenLocking.sol

Interface: ITokenLocking.sol

incrementLockCounterTo

Increment the token lock counter. This method allows users to waive reward payouts for past reward payout cycles, unlocking the tokens that were locked in previous reward payout cycles.

await tokenLockingClient.incrementLockCounterTo.send({
  token,
  lockId,
}, options);

Input

NameTypeDescription
tokenaddress (0x0 included)The address of the token contract (an empty address if Ether).
lockIdnumberThe ID of the lock count that will be set.

Options

See Sender for more information about options.

Response

An instance of a ContractResponse.

See Sender for more information about ContractResponse.

Contract Information

Contract: TokenLocking.sol

Interface: ITokenLocking.sol

unlockTokenForUser

Unlock all tokens for a user on a given token contract.

await tokenLockingClient.unlockTokenForUser.send({
  token,
  user,
  lockId,
}, options);

Input

NameTypeDescription
tokenaddress (0x0 included)The address of the token contract (an empty address if Ether).
useraddressThe address of the user.
lockIdnumberThe ID of the lock count that will be set.

Options

See Sender for more information about options.

Response

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

NameTypeDescription
tokenaddress (0x0 included)The address of the token contract that was unlocked.
useraddressThe address of the user that the tokens were unlocked for.
lockIdnumberThe ID of the lock that the was set for the user.
UserTokenUnlockedobjectContains the data defined in UserTokenUnlocked

See Sender for more information about ContractResponse.

Contract Information

Contract: TokenLocking.sol

Interface: ITokenLocking.sol

withdraw

Withdraw tokens. This function only be called if the tokens that the user is attempting to withdraw are not locked.

await tokenLockingClient.withdraw.send({
  token,
  amount,
}, options);

Input

NameTypeDescription
tokenaddress (0x0 included)The address of the token contract (an empty address if Ether).
amountbig numberThe amount of tokens that will be deposited.

Options

See Sender for more information about options.

Response

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

NameTypeDescription
tokenaddress (0x0 included)The address of the token contract from which tokens were withdrawn.
useraddressThe address of the user that withdrew tokens.
amountbig numberThe amount of tokens that were withdrawn.
UserTokenWithdrawnobjectContains the data defined in UserTokenWithdrawn

See Sender for more information about ContractResponse.

Contract Information

Contract: TokenLocking.sol

Interface: ITokenLocking.sol

Events

TokenLocked

Event Handler

const eventHandler = ({
  token,
  lockCount,
}) => {
  // perform an action using the event data
};

Add Listener

tokenLockingClient.events.TokenLocked.addListener(eventHandler);

Remove Listener

tokenLockingClient.events.TokenLocked.removeListener(eventHandler);

Event Data

NameTypeDescription
tokenaddress (0x0 included)The address of the token contract that was locked.
lockCountbig numberThe address of the token contract that was assigned.

UserTokenDeposited

Event Handler

const eventHandler = ({
  token,
  user,
  amount,
  timestamp,
}) => {
  // perform an action using the event data
};

Add Listener

tokenLockingClient.events.UserTokenDeposited.addListener(eventHandler);

Remove Listener

tokenLockingClient.events.UserTokenDeposited.removeListener(eventHandler);

Event Data

NameTypeDescription
tokenaddress (0x0 included)The address of the token contract receiving the deposit.
useraddressThe address of the user that deposited tokens.
amountbig numberThe amount of tokens that were deposited.
timestampdateThe timestamp when the tokens were deposited.

UserTokenUnlocked

Event Handler

const eventHandler = ({
  token,
  user,
  lockId,
}) => {
  // perform an action using the event data
};

Add Listener

tokenLockingClient.events.UserTokenUnlocked.addListener(eventHandler);

Remove Listener

tokenLockingClient.events.UserTokenUnlocked.removeListener(eventHandler);

Event Data

NameTypeDescription
tokenaddress (0x0 included)The address of the token contract that was unlocked.
useraddressThe address of the user that the tokens were unlocked for.
lockIdnumberThe ID of the lock that the was set for the user.

UserTokenWithdrawn

Event Handler

const eventHandler = ({
  token,
  user,
  amount,
}) => {
  // perform an action using the event data
};

Add Listener

tokenLockingClient.events.UserTokenWithdrawn.addListener(eventHandler);

Remove Listener

tokenLockingClient.events.UserTokenWithdrawn.removeListener(eventHandler);

Event Data

NameTypeDescription
tokenaddress (0x0 included)The address of the token contract from which tokens were withdrawn.
useraddressThe address of the user that withdrew tokens.
amountbig numberThe amount of tokens that were withdrawn.

Support

Questions? Problems? Existential dilemmas? We’re here to help!

Improve this doc.

All improvements to documentation are welcome and encouraged. Submit a PR for documentation on GitHub.