Skip to content

transferFrom ​

Standard ERC-20 transfer of vault shares from from to to, using the caller's allowance.

Signature ​

solidity
function transferFrom(address from, address to, uint256 value) external returns (bool);

Parameters ​

NameTypeDescription
fromaddressAddress whose shares are spent.
toaddressRecipient of the shares.
valueuint256Amount of shares to move (18 decimals).

Returns ​

true on success. Reverts on failure.

Preconditions ​

  • from and to must be non-zero addresses.
  • from must hold at least value shares.
  • The caller must have allowance(from, msg.sender) >= value. Set this with approve (called by from).

Events emitted ​

solidity
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value); // updated allowance

Example — pull 5 shares using a prior allowance ​

ts
import { parseUnits } from 'viem'
import { publicClient, walletClient } from './client'
import { liteUsdVaultAbi } from './abi'
import { VAULT, SHARE_DECIMALS } from './constants'

const FROM = '0x...' as const
const TO   = '0x...' as const
const value = parseUnits('5', SHARE_DECIMALS)

const { request } = await publicClient.simulateContract({
  account: walletClient.account!,
  address: VAULT,
  abi: liteUsdVaultAbi,
  functionName: 'transferFrom',
  args: [FROM, TO, value],
})

const hash = await walletClient.writeContract(request)
await publicClient.waitForTransactionReceipt({ hash })

Notes ​

  • transferFrom is the underlying mechanism behind third-party withdraw / redeem calls — when owner != msg.sender, the vault internally consumes share allowance the same way.