Secure the networkBug Bounty 2019

TokenClient

The TokenClient is a standard interface for interactions with methods and events described in Token.sol. These interactions are extended from the ERC20 and DSToken standard token interfaces and are generally concerned with managing the native token assigned to a colony. This includes operations such as minting tokens, burning tokens, and transferring tokens.

See Clients for information about initializing TokenClient.

Callers

All callers return promises which resolve to an object containing the given return values..

getAllowance.call({ sourceAddress, user })

Get the token allowance of an address. The allowance is the amount of tokens that the spender is authorized to transfer using the transferFrom function.

Arguments

ArgumentTypeDescription
sourceAddressaddressThe address that approved the allowance (the token owner ).
useraddressThe address that was approved for the allowance (the token spender ).

Return Values

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

Return ValueTypeDescription
amountbig numberThe amount of tokens that were approved (the amount allowed ).

Contract Information

Function: allowance

Contract: erc20.sol

getBalanceOf.call({ sourceAddress })

Get the the token balance of an address.

Arguments

ArgumentTypeDescription
sourceAddressaddressThe address that will be checked.

Return Values

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

Return ValueTypeDescription
amountbig numberThe balance of tokens for the address.

Contract Information

Function: balanceOf

Contract: erc20.sol

getTokenInfo.call()

Get information about the token.

Return Values

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

Return ValueTypeDescription
namestringThe name of the token.
symbolstringThe symbol of the token.
decimalsnumberThe number of decimals.

Contract Information

Contract: Token.sol

getTotalSupply.call()

Get the total supply of the token.

Return Values

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

Return ValueTypeDescription
amountbig numberThe total supply of the token.

Contract Information

Function: totalSupply

Contract: erc20.sol

Senders

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

approve.send({ user, amount }, options)

Approve a token allowance. This function can only be called by the token owner. The allowance is the amount of tokens that the spender is authorized to transfer using the transferFrom function.

Arguments

ArgumentTypeDescription
useraddressThe address that will be approved for the allowance (the token spender ).
amountbig numberThe amount of tokens that will be approved (the amount allowed ).

Response

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

Event DataTypeDescription
owneraddressThe address that approved the allowance (the token owner ).
spenderaddressThe address that was approved for the allowance (the token spender ).
valuebig numberThe amount of tokens that were approved (the amount allowed ).
ApprovalobjectContains the data defined in Approval

Contract Information

Contract: erc20.sol

burn.send({ user, amount }, options)

Burn tokens. This is a DSToken function that can only be called by the token owner. When a colony contract address is assigned as the token owner, this function can only be called by the user assigned the FOUNDER authority role.

Arguments

ArgumentTypeDescription
useraddressThe address from which the tokens will be burned.
amountbig numberThe amount of tokens that will be burned.

Response

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

Event DataTypeDescription
addressaddressThe address from which the tokens were burned.
amountbig numberThe amount of tokens that were burned.
BurnobjectContains the data defined in Burn

Contract Information

Contract: token.sol

mint.send({ user, amount }, options)

Mint new tokens. This is a DSToken function that can only be called by the token owner. When a colony contract address is assigned as the token owner, this function can only be called by the user assigned the FOUNDER authority role.

Arguments

ArgumentTypeDescription
useraddressThe address that will receive the minted tokens.
amountbig numberThe amount of tokens that will be minted.

Response

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

Event DataTypeDescription
addressaddressThe address to which the minted tokens were sent.
amountbig numberThe amount of tokens that were minted.
MintobjectContains the data defined in Mint

Contract Information

Contract: token.sol

setAuthority.send({ authority }, options)

Assign an account the ADMIN authority role within a colony.

Arguments

ArgumentTypeDescription
authorityaddressThe address that will be assigned the ADMIN authority role.

Response

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

Event DataTypeDescription
authorityaddressThe address that was assigned an authority role.
LogSetAuthorityobjectContains the data defined in LogSetAuthority

Contract Information

Contract: auth.sol

setName.send({ name }, options)

Set the name of a token contract. This function can only be called by the current owner of the contract. In order to call token contract methods from within a colony, the token owner must be the address of the colony contract.

Arguments

ArgumentTypeDescription
namestringThe name of the token that will be set.

Response

An instance of a ContractResponse

Contract Information

Contract: token.sol

setOwner.send({ owner }, options)

Set the owner of a token contract. This function can only be called by the current owner of the contract. In order to call token contract methods from within a colony, the token owner must be the address of the colony contract.

Arguments

ArgumentTypeDescription
owneraddressThe address that will be assigned as the new owner.

Response

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

Event DataTypeDescription
owneraddressThe address that was assigned as the new owner.
LogSetOwnerobjectContains the data defined in LogSetOwner

Contract Information

Contract: auth.sol

transfer.send({ destinationAddress, amount }, options)

Transfer tokens from the address calling the function to another address. The current address must have a sufficient token balance.

Arguments

ArgumentTypeDescription
destinationAddressaddressThe address to which tokens will be transferred.
amountbig numberThe amount of tokens that will be transferred.

Response

An instance of a ContractResponse

Contract Information

Contract: erc20.sol

transferFrom.send({ sourceAddress, destinationAddress, amount }, options)

Transfer tokens from one address to another address. The address the tokens are transferred from must have a sufficient token balance and it must have a sufficient token allowance approved by the token owner.

Arguments

ArgumentTypeDescription
sourceAddressaddressThe address from which tokens will be transferred.
destinationAddressaddressThe address to which tokens will be transferred.
amountbig numberThe amount of tokens that will be transferred.

Response

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

Event DataTypeDescription
fromaddressThe address of the account that sent tokens.
toaddressThe address of the account that received tokens.
valuebig numberThe amount of tokens that were transferred.
TransferobjectContains the data defined in Transfer

Contract Information

Contract: Token.sol

Events

events.Approval.addListener(({ owner, spender, value }) => { /* ... */ })

Arguments

ArgumentTypeDescription
owneraddressThe address that approved the allowance (the token owner ).
spenderaddressThe address that was approved for the allowance (the token spender ).
valuebig numberThe amount of tokens that were approved (the amount allowed ).

events.Burn.addListener(({ address, amount }) => { /* ... */ })

Arguments

ArgumentTypeDescription
addressaddressThe address from which the tokens were burned.
amountbig numberThe amount of tokens that were burned.

events.LogSetAuthority.addListener(({ authority }) => { /* ... */ })

Arguments

ArgumentTypeDescription
authorityaddressThe address that was assigned an authority role.

events.LogSetOwner.addListener(({ owner }) => { /* ... */ })

Arguments

ArgumentTypeDescription
owneraddressThe address that was assigned as the new owner.

events.Mint.addListener(({ address, amount }) => { /* ... */ })

Arguments

ArgumentTypeDescription
addressaddressThe address to which the minted tokens were sent.
amountbig numberThe amount of tokens that were minted.

events.TokenLocked.addListener(({ token, lockCount }) => { /* ... */ })

Arguments

ArgumentTypeDescription
tokenaddressThe address of the token contract.
lockCountnumberThe total lock count for the token.

events.Transfer.addListener(({ from, to, value }) => { /* ... */ })

Arguments

ArgumentTypeDescription
fromaddressThe address of the account that sent tokens.
toaddressThe address of the account that received tokens.
valuebig numberThe amount of tokens that were transferred.