Back to Contract Explorer

FundingFacet

core

Handles depositing collateral into the Smart Loan account. Tokens must be approved to the loan address before calling fund().

Functions (2)

Usage Example

typescript
import { createWalletClient, http, encodePacked, keccak256 } from "viem";
import { base } from "viem/chains";

const tokenId = keccak256(encodePacked(["string"], ["USDC"]));
const amount = 1000n * 10n ** 6n; // 1000 USDC

// First: approve the token
await walletClient.writeContract({
  address: usdcAddress,
  abi: erc20Abi,
  functionName: "approve",
  args: [loanAddress, amount],
});

// Then: fund the loan
await walletClient.writeContract({
  address: loanAddress,
  abi: fundingFacetAbi,
  functionName: "fund",
  args: [tokenId, amount],
});