Skip to main content

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

NameTypeDescription
chainIdnumberBaseCurrency#chainId
addressstringThe contract address on the chain on which this token lives
decimalsnumberBaseCurrency#decimals
symbol?stringBaseCurrency#symbol
name?stringBaseCurrency#name
bypassChecksum?booleanIf true it only checks for length === 42, startsWith 0x and contains only hex characters

Overrides

BaseCurrency.constructor

Defined in

entities/token.ts:27

Properties

address

Readonly address: string

The contract address on the chain on which this token lives

Defined in

entities/token.ts:16


chainId

Readonly chainId: number

The chain ID on which this currency resides

Inherited from

BaseCurrency.chainId

Defined in

entities/baseCurrency.ts:21


decimals

Readonly decimals: number

The decimals used in representing currency amounts

Inherited from

BaseCurrency.decimals

Defined in

entities/baseCurrency.ts:25


isNative

Readonly isNative: false

Overrides

BaseCurrency.isNative

Defined in

entities/token.ts:10


isToken

Readonly isToken: true

Overrides

BaseCurrency.isToken

Defined in

entities/token.ts:11


name

Optional Readonly name: string

The name of the currency, i.e. a descriptive textual non-unique identifier

Inherited from

BaseCurrency.name

Defined in

entities/baseCurrency.ts:33


symbol

Optional Readonly symbol: string

The symbol of the currency, i.e. a short textual non-unique identifier

Inherited from

BaseCurrency.symbol

Defined in

entities/baseCurrency.ts:29

Accessors

wrapped

get wrapped(): Token

Return this token, which does not need to be wrapped

Returns

Token

Overrides

BaseCurrency.wrapped

Defined in

entities/token.ts:66

Methods

equals

equals(other): boolean

Returns true if the two tokens are equivalent, i.e. have the same chainId and address.

Parameters

NameTypeDescription
otherCurrencyother token to compare

Returns

boolean

Overrides

BaseCurrency.equals

Defined in

entities/token.ts:47


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

NameTypeDescription
otherTokenother token to compare

Returns

boolean

Defined in

entities/token.ts:57