Interact with tokens

The Token module is the core of the TREX SDK.
It retrieves information about tokens and checks the compliance of Identities and transfers according to the token's rules. It also interacts with the Tokens contracts to update their state and their registries.

You can load a token using the Token.at() static asynchronous method either as a Signer or as a Provider. This method resolves ENS as well.

import { Token } from "@tokenyico/trex-sdk";

const token = await Token.at('TOKEN CONTRACT ADDRESS', { signer });

The created token object will retain the provider it was instantiated with, so all methods call on it will use this provider unless override in options parameters of these methods.

Token instance

Should you need to call any methods not implemented in the SDK, you can retrieve the Token contract instance. This instance returns an Ethers Contract loaded with the Token interface ABI as defined in the T-REX Standard.

const token = await Token.at('TOKEN CONTRACT ADDRESS', { provider });

const tokenInstance: Ethers.Contract = await token.getTokenInstance({ provider });
const tokenInstance: Ethers.Contract = await token.getTokenInstance({ provider });

or more simply

const token = await Token.at('TOKEN CONTRACT ADDRESS', { provider });

const tokenInstance: Ethers.Contract = await token.token;