SDK Configuration
Creating a Configuration

Create a Tenderize Config

The Tenderize SDK facilitates interaction with blockchain networks using Alchemy as the provider. Below is a comprehensive guide on configuring the SDK using TypeScript definitions and essential setup instructions.

Example use case

The following example demonstrates how to create a configuration for the Tenderize SDK using TypeScript. This configuration includes tenderizers, chain mappings, token specifications, token metadata, and an Alchemy API key.

CreateConfig
import { TokenSlugEnums, createTenderizeConfig } from "@tenderize/sdk";
 
const config = createTenderizeConfig({
  appName: "Tenderize App",
  tenderizers: TENDERIZERS,
  chains: CHAINS,
  tokens: [TokenSlugEnums.MATIC, TokenSlugEnums.LIVEPEER],
  tokenMetadata: {
    [TokenSlugEnums.MATIC]: {
      name: "tMATIC Stake Capital",
      avatar: "https://example.com/avatar.png", // Valid URL for custom avatar
    },
    [TokenSlugEnums.LIVEPEER]: {
      name: "tLPT Stake Capital",
      avatar: "https://example.com/lpt-avatar.png", // Valid URL for custom avatar
    },
  },
  apiKey: ALCHEMY_API_KEY as string,
  walletConnectProjectId: WALLETCONNECT_PROJECT_ID as string,
});

Explanation

In this example, we import the TokenSlugEnums and createTenderizeConfig functions from the @tenderize/sdk package. We then define a configuration object using these functions.

tenderizers: Specifies the tenderizers configuration object defined earlier.

chains: Specifies the chain mappings for the tokens.

tokens: Lists the tokens to be included in the configuration (e.g., MATIC and LIVEPEER).

tokenMetadata: Provides metadata for each token, such as the token name.

apiKey: Your Alchemy API key as a string.

walletConnectProjectId: Your Wallet connect project id as a string.

Return Type

After invoking createTenderizeConfig, the function returns a TenderizeConfig object. This configuration object is essential for initializing both the Web3Provider and the TenderizeProvider, ensuring that your application is correctly set up to interact with the blockchain network.

Return
export type TenderizeConfig = {
  tenderizers: TenderizersConfig;
  chains: TenderizeChains;
  web3: Config;
  tokens?: TokenSlugEnums[];
  tokenMetadata?: {
    [key in TokenSlugEnums]?: TokenMetadata;
  };
};

TenderizeConfig

The TenderizeConfig type defines the structure of the configuration object returned by the createTenderizeConfig function. It includes the following properties:

  • tenderizers: An object containing the tenderizer configurations.
  • chains: An object mapping tokens to their respective chain configurations.
  • web3: The web3 configuration object.
  • tokens (optional): An array of token slugs included in the configuration.
  • tokenMetadata (optional): An object providing metadata for each token, indexed by token slugs.
ℹ️

Additional Notes : Ensure that all required configurations are properly defined to allow the Tenderize SDK to interact seamlessly with blockchain networks. This returned configuration object will be used to initialize and operate the SDK within your application.