Wrapper EnhancementsGlobalsKosuToken

# Class: KosuToken

The KosuToken class is a wrapper for the Kosu ERC-20 token contract, and provides all necessary methods for interacting with the contract on any Ethereum network for which the contract has been deployed.

If instantiated outside the Kosu class, an instance of web3 and of the web3Wrapper must be supplied in the options object.

# Hierarchy

  • KosuToken

# Index

# Constructors

# Properties

# Methods

# Constructors

# constructor

+ new KosuToken(options: KosuOptions): KosuToken

Defined in KosuToken.ts:38

Creates a new KosuToken instance, supplied with an options object.

The KosuToken address may be passed in as options.kosuTokenAddress, but can also be loaded during each method call from the known deployed addresses.

example

const options = { web3: new Web3(window.ethereum), web3Wrapper };
const kosuToken = new KosuToken(options);

Parameters:

Name Type Description
options KosuOptions initialization options object (incl. web3 and web3wrapper)

Returns: KosuToken

# Properties

# address

address: string

Defined in KosuToken.ts:33

The current KosuToken deployed address, loaded based on the detected networkId from a mapping of known deployed addresses.


# coinbase

coinbase: string

Defined in KosuToken.ts:38

The user's coinbase address (if available via supplied provider).


# contract

contract: KosuTokenContract

Defined in KosuToken.ts:27

An instance of the lower-level contract wrapper for the Kosu token, auto- generated from the Solidity source code.


# web3Wrapper

web3Wrapper: Web3Wrapper

Defined in KosuToken.ts:21

An instance of a 0x Web3Wrapper used for some RPC calls and for certain methods.

# Methods

# allowance

allowance(owner: string, spender: string): Promise‹BigNumber›

Defined in KosuToken.ts:157

Reads approved allowance for a given owner and spender account.

Parameters:

Name Type Description
owner string Address of source tokens
spender string Address of spender of tokens

Returns: Promise‹BigNumber›

The allowance granted to the spender in units of wei.


# approve

approve(spender: string, value: BigNumber | string | number): Promise‹TransactionReceiptWithDecodedLogs›

Defined in KosuToken.ts:142

Sets approval for user to transfer tokens on coinbase's behalf.

Parameters:

Name Type Description
spender string Address allowed to spend coinbase's tokens.
value BigNumber | string | number The uint value (in wei) to approve spender for.

Returns: Promise‹TransactionReceiptWithDecodedLogs›

The transaction receipt after it has been included in a block.


# balanceOf

balanceOf(owner: string): Promise‹BigNumber›

Defined in KosuToken.ts:101

Reads the balance for a user address, returned in wei.

Parameters:

Name Type Description
owner string The Ethereum address of a token holder.

Returns: Promise‹BigNumber›

The owner's KOSU balance in wei.


# bondTokens

bondTokens(value: BigNumber, minPayout: BigNumber | string | number): Promise‹TransactionReceiptWithDecodedLogs›

Defined in KosuToken.ts:191

Sends ether to the contract to bond tokens.

Parameters:

Name Type Description
value BigNumber Amount of wei to deposit
minPayout BigNumber | string | number Minimum amount of tokens required to be minted to prevent transaction from reverting.

Returns: Promise‹TransactionReceiptWithDecodedLogs›

Logs from the transaction block.


# estimateEtherToToken

estimateEtherToToken(etherInput: BigNumber | string | number): Promise‹BigNumber›

Defined in KosuToken.ts:168

Calculated tokens to be minted from deposited ether.

Parameters:

Name Type Description
etherInput BigNumber | string | number Amount of ether to be submitted to generate tokens.

Returns: Promise‹BigNumber›

Estimation of tokens to be minted.


# estimateTokenToEther

estimateTokenToEther(tokensToBurn: BigNumber | string | number): Promise‹BigNumber›

Defined in KosuToken.ts:179

Calculates ether to be returned for burning tokens.

Parameters:

Name Type Description
tokensToBurn BigNumber | string | number Amount of tokens to burn for returned ether.

Returns: Promise‹BigNumber›

Estimation of ether to be returned.


# getContract

getContract(): Promise‹KosuTokenContract›

Defined in KosuToken.ts:63

Asynchronously initializes the contract instance or returns it from cache.

Returns: Promise‹KosuTokenContract›

The low-level KosuToken contract wrapper instance.


# pay

pay(value: BigNumber | string | number): Promise‹TransactionReceiptWithDecodedLogs›

Defined in KosuToken.ts:218

Sends ether to the contract to bond tokens.

Parameters:

Name Type Description
value BigNumber | string | number Amount of wei to deposit

Returns: Promise‹TransactionReceiptWithDecodedLogs›

Logs from the transaction block.


# releaseTokens

releaseTokens(tokensToBurn: BigNumber | string | number): Promise‹TransactionReceiptWithDecodedLogs›

Defined in KosuToken.ts:207

Releases tokens to be burned and return bonded ether.

Parameters:

Name Type Description
tokensToBurn BigNumber | string | number Amount of tokens to burn for returned ether.

Returns: Promise‹TransactionReceiptWithDecodedLogs›

Logs from the transaction block.


# totalSupply

totalSupply(): Promise‹BigNumber›

Defined in KosuToken.ts:90

Reads the total supply of KOSU, resolves to a BigNumber of the amount of tokens in units of wei.

Returns: Promise‹BigNumber›

The total KOSU supply in wei.


# transfer

transfer(to: string, value: BigNumber | string | number): Promise‹TransactionReceiptWithDecodedLogs›

Defined in KosuToken.ts:113

Transfers tokens to an address, from the current coinbase account.

Parameters:

Name Type Description
to string Ethereum Address of token receiver.
value BigNumber | string | number The uint value of tokens to transfer (in wei).

Returns: Promise‹TransactionReceiptWithDecodedLogs›

The transaction's receipt after inclusion in a block.


# transferFrom

transferFrom(from: string, to: string, value: BigNumber | string | number): Promise‹TransactionReceiptWithDecodedLogs›

Defined in KosuToken.ts:126

Transfers token from an address to a destination address.

Parameters:

Name Type Description
from string Address of token source.
to string Address of token destination.
value BigNumber | string | number The uint value of tokens to transfer (in wei).

Returns: Promise‹TransactionReceiptWithDecodedLogs›

The transaction receipt after it has been included in a block.