Skip to content

Enzyme SDK - Overview

The Enzyme SDK is based on viem. It facilitates making on-chain calls and sending transactions.

Quick Start

To use the Enzyme SDK, add @enzymefinance/sdk to your TypeScript project:

pnpm
pnpm add @enzymefinance/sdk viem

1. Set up Viem

Create a public client (see also the Public Client) to be able to make on-chain calls.

import { createPublicClient, http } from "viem";
import { polygon } from "viem/chains";
 
const publicClient = createPublicClient({  
  chain: polygon, 
  transport: http(), 
}); 

Create a wallet client (see also Wallet Client) to be able to send transactions.

import { createWalletClient, http } from "viem";
import { polygon } from "viem/chains";
 
const account = privateKeyToAccount(process.env.PRIVATE_KEY as Hex); 
 
const walletClient = createWalletClient({ 
  account, 
  chain: polygon, 
  transport: http(), 
}); 

2. Use the Enzyme SDK

Use the public client to make on-chain calls.

import { Vault } from "@enzymefinance/sdk"; 
 
const name = await Vault.getName(publicClient, {  
  vaultProxy, 
}); 

Use the wallet client to send a transaction. The Enzyme SDK provides properly typed functions for all transaction within the Enzyme protocol.

import { Portfolio } from "@enzymefinance/sdk";
 
const transaction = Portfolio.removeTracketAssets({  
  removeAssets: ["0x1a13f4ca1d028320a707d99520abfefca3998b7f"], 
  comptrollerProxy, 
  integrationManager, 
}); 
 
const transactionResult =
  await walletClient.sendTransaction(transaction.params); 
 
console.log("transaction hash: ", transactionResult);