Skip to main content

staticTokenDefinition.ts

path: /src/utils/staticTokenDefinition.ts

Class StaticTokenDefinition

A utility class to represent an ERC20 token metadata. Contains four fields:

FieldType
addressAddress
symbolstring
namestring
decimalsBigInt

It has a constructor to initialized an object:

constructor(address: Address, symbol: string, name: string, decimals: BigInt)

The class exposes two static functions:

  1. getStaticDefinitions()
  2. fromAddress()

getStaticDefinitions()

Returns an Array<StaticTokenDefinition> object with the token definitions defined with the function:

AddressSymbolNameDecimals
0xe0b7927c4af23765cb51314a0e0521a9645f0e2aDGDDGD9
0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9AAVEAave Token18
0xeb9951021698b42e4399f9cbb6267aa35f82d59dLIFLif18
0xbdeb4b83251fb146687fa19d1c660f99411eefe3SVDsavedroid18
0xbb9bc244d798123fde783fcc1c72d3bb8c189413TheDAOTheDAO16
0x38c6a68304cdefb9bec48bbfaaba5c5b47818bb2HPBHPBCoin18

Invoked at:

  1. fromAddress()

fromAddress()

Params:
- tokenAddress (Address): the ERC20 address to search for in the ERC20 symbols defined in StaticTokenDefinition class

ReturnType: StaticTokenDefinition | null

Get an Array of StaticTokenDefinition objects from static method getStaticDefinition() and iterates through them to find the tokenAddress, If found returns the StaticTokenDefinition object, else returns null.

Dependencies:

  1. getStaticDefinitions()

Invoked at:

  1. fetchTokenSymbol()
  2. fetchTokenName()
  3. fetchTokenDecimals()