Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Submit a vault deposit transaction with the SDK.
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!, });
const erc4626DepositAbi = [ { name: "deposit", type: "function", stateMutability: "nonpayable", inputs: [ { name: "assets", type: "uint256" }, { name: "receiver", type: "address" }, ], outputs: [{ name: "shares", type: "uint256" }], }, ]; const callData = encodeFunctionData({ abi: erc4626DepositAbi, functionName: "deposit", args: [1_000_000_000n, "0xReceiver..."], });
const { data: queued } = await client.createTransaction({ accountId: "acc_123", initiatorWalletAddress: signer.address, networkId: 1, policyId: "pol_123", description: "Deposit into vault", to: "0xVaultAddress...", value: "0", data: callData, });
const initiatorSig = encodeAbiParameters( [ { type: "address", name: "address" }, { type: "bytes", name: "signature" }, ], [ signer.address, await signer.sign({ hash: queued.signatureData.initiatorPayload as Hex, }), ] ); const { data: afterInitiator } = await client.signTransaction(queued.id, { type: "initiator", signature: initiatorSig, }); if (afterInitiator.signatureData.status === "approvalReady") { await client.executeTransaction(queued.id, { type: "approve" }); }
import { DenClient } from "@onchainden/mls-sdk-ts"; import { privateKeyToAccount } from "viem/accounts"; import { encodeFunctionData } from "viem"; // 1) Set up the client and signer. 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. const erc4626DepositAbi = [ { name: "deposit", type: "function", stateMutability: "nonpayable", inputs: [ { name: "assets", type: "uint256" }, { name: "receiver", type: "address" }, ], outputs: [{ name: "shares", type: "uint256" }], }, ]; const callData = encodeFunctionData({ abi: erc4626DepositAbi, functionName: "deposit", args: [1_000_000_000n, "0xReceiver..."], }); // 3) Create the deposit transaction. const { data: queued } = await client.createTransaction({ accountId: "acc_123", initiatorWalletAddress: signer.address, networkId: 1, policyId: "pol_123", description: "Deposit into vault", to: "0xVaultAddress...", value: "0", data: callData, }); // 4) Sign and execute. const initiatorSig = encodeAbiParameters( [ { type: "address", name: "address" }, { type: "bytes", name: "signature" }, ], [ signer.address, await signer.sign({ hash: queued.signatureData.initiatorPayload as Hex, }), ] ); const { data: afterInitiator } = await client.signTransaction(queued.id, { type: "initiator", signature: initiatorSig, }); if (afterInitiator.signatureData.status === "approvalReady") { await client.executeTransaction(queued.id, { type: "approve" }); }