Token
@pegasys-fi/sdk-core / Exports / Token
Class: Token
Represents an ERC20 token with a unique address and some metadata.
Hierarchy
BaseCurrency
↳
Token
Table of contents
Constructors
Properties
Accessors
Methods
Constructors
constructor
• new Token(chainId
, address
, decimals
, symbol?
, name?
, bypassChecksum?
)
Parameters
Name | Type | Description |
---|---|---|
chainId | number | BaseCurrency#chainId |
address | string | The contract address on the chain on which this token lives |
decimals | number | BaseCurrency#decimals |
symbol? | string | BaseCurrency#symbol |
name? | string | BaseCurrency#name |
bypassChecksum? | boolean | If true it only checks for length === 42, startsWith 0x and contains only hex characters |
Overrides
BaseCurrency.constructor
Defined in
Properties
address
• Readonly
address: string
The contract address on the chain on which this token lives
Defined in
chainId
• Readonly
chainId: number
The chain ID on which this currency resides
Inherited from
BaseCurrency.chainId
Defined in
decimals
• Readonly
decimals: number
The decimals used in representing currency amounts
Inherited from
BaseCurrency.decimals
Defined in
isNative
• Readonly
isNative: false
Overrides
BaseCurrency.isNative
Defined in
isToken
• Readonly
isToken: true
Overrides
BaseCurrency.isToken
Defined in
name
• Optional
Readonly
name: string
The name of the currency, i.e. a descriptive textual non-unique identifier
Inherited from
BaseCurrency.name
Defined in
symbol
• Optional
Readonly
symbol: string
The symbol of the currency, i.e. a short textual non-unique identifier
Inherited from
BaseCurrency.symbol
Defined in
Accessors
wrapped
• get
wrapped(): Token
Return this token, which does not need to be wrapped
Returns
Overrides
BaseCurrency.wrapped
Defined in
Methods
equals
▸ equals(other
): boolean
Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
Parameters
Name | Type | Description |
---|---|---|
other | Currency | other token to compare |
Returns
boolean
Overrides
BaseCurrency.equals
Defined in
sortsBefore
▸ sortsBefore(other
): boolean
Returns true if the address of this token sorts before the address of the other token
Throws
if the tokens have the same address
Throws
if the tokens are on different chains
Parameters
Name | Type | Description |
---|---|---|
other | Token | other token to compare |
Returns
boolean