Token
Token represents an ERC20 token with a unique address and additional data on whether the token is a native currency. The Token class ensures Token equivalence when executing functions.
GitHub File: token.ts
Extends
Properties
Public
Property | Type | Modifier | Description |
---|---|---|---|
address | string | readonly | The token contract address. |
chainId | readonly | The chain ID on which this currency resides. See supported chains. | |
chainType | readonly | The virtual machine environment. Currently supports EVM only. | |
decimals | number | readonly | Number of decimals for the currency. |
symbol | string | readonly | The currency symbol. Optional. |
name | string | readonly | The currency name. Optional. |
isNative | boolean | readonly | Whether the currency is native to the chain and must be wrapped. |
isToken | boolean | readonly | Whether the currency meets the ERC20 standard and if not, needs to be wrapped. |
Note that the mint
property was previously used to manage Solana tokens but support for Solana on KyberSwap has since been deprecated.
Constructor
Parameters
Params | Type | Description |
---|---|---|
chainId | number | The chain ID on which this currency resides. See supported chains. |
address | string | The token contract address. |
decimals | number | Number of decimals for the currency. |
symbol | string | The currency symbol. Optional. |
name | string | The currency name. Optional. |
Methods
equals() - public
public
Returns whether the token passed in the argument is functionally equivalent to the token implementing this class (i.e. same contract address on the same chain).
Parameters
Params | Type | Description |
---|---|---|
other | Token | The token to check against. |
Returns
Type | Description |
---|---|
boolean | Indicates whether the token passed in the argument is functionally equivalent to the token implementing this class. |
sortsBefore() - public
public
Returns true if the token's contract address sorts before the input token contract address. Also checks if the tokens are equivalent else throws an error (i.e. same contract address and chain).
Parameters
Params | Type | Description |
---|---|---|
other | Token | The currency to check against. |
Returns
Type | Description |
---|---|
boolean |
|
wrapped() - public
get
public
get
Accessor that returns this ERC20 token.
Returns
Type | Description |
---|---|
Token | The token implementing this class. |
Last updated