A vault deposit transaction sends assets into a DeFi vault (often ERC-4626) and
receives vault shares in return. This example uses an ERC-4626 vault deposit.
Adjust the contract address, function signature, and amount for your protocol.
1) Set up the client and signer
Create the SDK client and signer used for approvals.
import { DenClient } from "@onchainden/mls-sdk-ts";import { privateKeyToAccount } from "viem/accounts";import { encodeAbiParameters, encodeFunctionData, type Hex } from "viem";const signer = privateKeyToAccount("0xYOUR_PRIVATE_KEY");const client = new DenClient({ apiKey: process.env.DEN_API_KEY!, baseUrl: process.env.DEN_API_BASE_URL!,});
2) Encode the vault deposit
Encode the ERC-4626 deposit call data for the vault.