> ## Documentation Index
> Fetch the complete documentation index at: https://www.zkcompression.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Transfer Interface

> Transfer tokens between Light Token, SPL and Token 2022 accounts. The interface checks decimals under the hood and detects account types to invoke the right programs.

export const lightTransferRustCode = ["use light_token::instruction::TransferInterface;", "", "let ix = TransferInterface {", "    source,", "    destination,", "    amount,", "    decimals,", "    authority: payer.pubkey(),", "    payer: payer.pubkey(),", "    spl_interface: None,", "    max_top_up: None,", "    source_owner: LIGHT_TOKEN_PROGRAM_ID,", "    destination_owner: LIGHT_TOKEN_PROGRAM_ID,", "}", ".instruction()?;"].join("\n");

export const splTransferRustCode = ["use spl_token::instruction::transfer;", "", "let ix = transfer(", "    &spl_token::id(),", "    &source,", "    &destination,", "    &authority,", "    &[],", "    amount,", ")?;"].join("\n");

export const lightTransferCode = ['import { transferInterface } from "@lightprotocol/compressed-token/unified";', "", "const tx = await transferInterface(", "  rpc,", "  payer,", "  sourceAta,", "  mint,", "  recipient,", "  owner,", "  amount", ");"].join("\n");

export const splTransferCode = ['import { transfer } from "@solana/spl-token";', "", "const tx = await transfer(", "  connection,", "  payer,", "  sourceAta,", "  destinationAta,", "  owner,", "  amount", ");"].join("\n");

export const CodeCompare = ({firstCode = "", secondCode = "", firstLabel = "Light Token", secondLabel = "SPL", language = "javascript"}) => {
  const [sliderPercent, setSliderPercent] = useState(100);
  const [isDragging, setIsDragging] = useState(false);
  const [isAnimating, setIsAnimating] = useState(false);
  const [copied, setCopied] = useState(false);
  const containerRef = useRef(null);
  const animationRef = useRef(null);
  const firstPreRef = useRef(null);
  const secondPreRef = useRef(null);
  const [containerHeight, setContainerHeight] = useState(null);
  const showingFirst = sliderPercent > 50;
  const handleCopy = async () => {
    const codeToCopy = showingFirst ? firstCode : secondCode;
    await navigator.clipboard.writeText(codeToCopy);
    setCopied(true);
    setTimeout(() => setCopied(false), 2000);
  };
  const highlightCode = code => {
    let escaped = code.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
    if (language === "rust") {
      const rustPattern = /(\/\/.*$)|(["'])(?:(?!\2)[^\\]|\\.)*?\2|\b(use|let|mut|pub|fn|struct|impl|enum|mod|const|static|trait|type|where|for|in|if|else|match|loop|while|return|self|Self|true|false|Some|None|Ok|Err|Result|Option|vec!)\b|::([a-zA-Z_][a-zA-Z0-9_]*)|&amp;([a-zA-Z_][a-zA-Z0-9_]*)|\b([a-zA-Z_][a-zA-Z0-9_]*)\s*(?=\()|(\?)/gm;
      return escaped.replace(rustPattern, (match, comment, stringQuote, keyword, pathSegment, reference, func, questionMark) => {
        if (comment) return `<span style="color:#6b7280;font-style:italic">${match}</span>`;
        if (stringQuote) return `<span style="color:#059669">${match}</span>`;
        if (keyword) return `<span style="color:#db2777">${match}</span>`;
        if (pathSegment) return `::<span style="color:#0891b2">${pathSegment}</span>`;
        if (reference) return `&amp;<span style="color:#6366f1">${reference}</span>`;
        if (func) return `<span style="color:#2563eb">${match}</span>`;
        if (questionMark) return `<span style="color:#db2777">?</span>`;
        return match;
      });
    }
    const pattern = /(\/\/.*$)|(["'`])(?:(?!\2)[^\\]|\\.)*?\2|\b(const|let|var|await|async|import|from|export|return|if|else|function|class|new|throw|try|catch)\b|\.([a-zA-Z_][a-zA-Z0-9_]*)\b|\b([a-zA-Z_][a-zA-Z0-9_]*)\s*(?=\()/gm;
    return escaped.replace(pattern, (match, comment, stringQuote, keyword, property, func) => {
      if (comment) return `<span style="color:#6b7280;font-style:italic">${match}</span>`;
      if (stringQuote) return `<span style="color:#059669">${match}</span>`;
      if (keyword) return `<span style="color:#db2777">${match}</span>`;
      if (property) return `.<span style="color:#0891b2">${property}</span>`;
      if (func) return `<span style="color:#2563eb">${match}</span>`;
      return match;
    });
  };
  const animateTo = target => {
    if (animationRef.current) cancelAnimationFrame(animationRef.current);
    setIsAnimating(true);
    const start = sliderPercent;
    const startTime = performance.now();
    const duration = 400;
    const animate = currentTime => {
      const elapsed = currentTime - startTime;
      const progress = Math.min(elapsed / duration, 1);
      const eased = 1 - Math.pow(1 - progress, 3);
      const current = start + (target - start) * eased;
      setSliderPercent(current);
      if (progress < 1) {
        animationRef.current = requestAnimationFrame(animate);
      } else {
        setSliderPercent(target);
        setIsAnimating(false);
        animationRef.current = null;
      }
    };
    animationRef.current = requestAnimationFrame(animate);
  };
  const handleToggle = () => {
    animateTo(showingFirst ? 0 : 100);
  };
  const handleMouseDown = e => {
    if (isAnimating) {
      cancelAnimationFrame(animationRef.current);
      setIsAnimating(false);
    }
    e.preventDefault();
    setIsDragging(true);
  };
  const handleMouseUp = () => {
    setIsDragging(false);
  };
  const handleMouseMove = e => {
    if (!isDragging || !containerRef.current) return;
    const rect = containerRef.current.getBoundingClientRect();
    const x = e.clientX - rect.left;
    const percent = Math.max(0, Math.min(100, x / rect.width * 100));
    setSliderPercent(percent);
  };
  const handleTouchMove = e => {
    if (!containerRef.current) return;
    if (isAnimating) {
      cancelAnimationFrame(animationRef.current);
      setIsAnimating(false);
    }
    const rect = containerRef.current.getBoundingClientRect();
    const x = e.touches[0].clientX - rect.left;
    const percent = Math.max(0, Math.min(100, x / rect.width * 100));
    setSliderPercent(percent);
  };
  const handleKeyDown = e => {
    if (e.key === "ArrowLeft") {
      setSliderPercent(p => Math.max(0, p - 5));
    } else if (e.key === "ArrowRight") {
      setSliderPercent(p => Math.min(100, p + 5));
    }
  };
  useEffect(() => {
    if (isDragging) {
      document.addEventListener("mousemove", handleMouseMove);
      document.addEventListener("mouseup", handleMouseUp);
      return () => {
        document.removeEventListener("mousemove", handleMouseMove);
        document.removeEventListener("mouseup", handleMouseUp);
      };
    }
  }, [isDragging]);
  useEffect(() => {
    return () => {
      if (animationRef.current) cancelAnimationFrame(animationRef.current);
    };
  }, []);
  useEffect(() => {
    const activeRef = showingFirst ? firstPreRef : secondPreRef;
    if (activeRef.current) {
      setContainerHeight(activeRef.current.scrollHeight);
    }
  }, [showingFirst]);
  return <>
      <div className="rounded-3xl not-prose mt-4 backdrop-blur-xl border overflow-hidden border-zinc-300 dark:border-zinc-700" style={{
    fontFamily: "Inter, sans-serif"
  }}>
        {}
        <div className="flex items-center justify-between px-4 py-3 border-b border-zinc-200 dark:border-zinc-700 bg-gray-50 dark:bg-zinc-900">
          <span className="text-sm font-medium text-zinc-600 dark:text-zinc-300">
            {showingFirst ? firstLabel : secondLabel}
          </span>

          <div className="flex items-center gap-3">
            {}
            <button onClick={handleCopy} className="p-1.5 rounded hover:bg-zinc-200 dark:hover:bg-zinc-700 transition-colors text-zinc-500 dark:text-zinc-400" title="Copy code" style={{
    background: "transparent",
    border: "none",
    cursor: "pointer"
  }}>
              {copied ? <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="#22c55e" strokeWidth="2">
                  <path d="M20 6L9 17l-5-5" />
                </svg> : <svg width="18" height="18" viewBox="0 0 18 18" fill="none">
                  <path d="M14.25 5.25H7.25C6.14543 5.25 5.25 6.14543 5.25 7.25V14.25C5.25 15.3546 6.14543 16.25 7.25 16.25H14.25C15.3546 16.25 16.25 15.3546 16.25 14.25V7.25C16.25 6.14543 15.3546 5.25 14.25 5.25Z" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
                  <path d="M2.80103 11.998L1.77203 5.07397C1.61003 3.98097 2.36403 2.96397 3.45603 2.80197L10.38 1.77297C11.313 1.63397 12.19 2.16297 12.528 3.00097" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
                </svg>}
            </button>

            {}
            <div onClick={handleToggle} className="bg-zinc-200 dark:bg-zinc-600" style={{
    position: "relative",
    width: "56px",
    height: "28px",
    borderRadius: "14px",
    boxShadow: "inset -2px -2px 4px rgba(255,255,255,0.3), inset 2px 2px 4px rgba(0,0,0,0.1)",
    cursor: "pointer",
    transition: "all 0.3s ease"
  }}>
              {}
              <div className="bg-white dark:bg-zinc-300" style={{
    position: "absolute",
    width: "24px",
    height: "24px",
    borderRadius: "12px",
    top: "2px",
    left: showingFirst ? "30px" : "2px",
    boxShadow: "0 2px 4px rgba(0,0,0,0.2)",
    transition: "all 0.3s ease-in-out",
    display: "flex",
    alignItems: "center",
    justifyContent: "center"
  }}>
                {}
                <div style={{
    width: "6px",
    height: "6px",
    background: showingFirst ? "#0066ff" : "#999",
    borderRadius: "50%",
    boxShadow: showingFirst ? "0 0 5px 1px rgba(0, 102, 255, 0.6)" : "0 0 4px 1px rgba(0, 0, 0, 0.1)",
    transition: "all 0.3s ease-in-out"
  }} />
              </div>
            </div>
          </div>
        </div>

        {}
        <div ref={containerRef} className="p-0" style={{
    cursor: isDragging ? "grabbing" : "default"
  }} onTouchMove={handleTouchMove} tabIndex={0} onKeyDown={handleKeyDown} role="slider" aria-valuenow={sliderPercent} aria-valuemin={0} aria-valuemax={100} aria-label="Code comparison slider">
          <div className="relative" style={{
    minHeight: "140px",
    overflow: "hidden",
    height: containerHeight ? `${containerHeight}px` : "auto",
    transition: "height 0.3s ease"
  }}>
            <div style={{
    position: "relative"
  }}>
              {}
              <pre ref={secondPreRef} className="m-0 p-4 text-zinc-700 dark:text-white/80 bg-transparent" style={{
    position: showingFirst ? "absolute" : "relative",
    top: 0,
    left: 0,
    right: 0,
    fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
    fontSize: "13px",
    lineHeight: "1.6",
    whiteSpace: "pre",
    zIndex: 1
  }} dangerouslySetInnerHTML={{
    __html: highlightCode(secondCode)
  }} />

              {}
              <pre ref={firstPreRef} className="m-0 p-4 text-zinc-700 dark:text-white/80 bg-white dark:bg-zinc-900" style={{
    position: showingFirst ? "relative" : "absolute",
    top: 0,
    left: 0,
    right: 0,
    fontFamily: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
    fontSize: "13px",
    lineHeight: "1.6",
    whiteSpace: "pre",
    zIndex: 2,
    clipPath: `inset(0 ${100 - sliderPercent}% 0 0)`
  }} dangerouslySetInnerHTML={{
    __html: highlightCode(firstCode)
  }} />
            </div>

            {}
            <div className="absolute top-0 bottom-0 flex items-center justify-center pointer-events-none" style={{
    left: `${sliderPercent}%`,
    transform: "translateX(-50%)",
    zIndex: 30
  }}>
              <div className="absolute top-0 bottom-0 w-px bg-zinc-400 dark:bg-white/30" />

              <div className="absolute top-0 bottom-0" style={{
    right: "50%",
    width: "60px",
    background: "linear-gradient(to left, rgba(0, 102, 255, 0.15) 0%, transparent 100%)"
  }} />

              {}
              <div onMouseDown={handleMouseDown} className="pointer-events-auto cursor-grab flex items-center justify-center gap-px transition-transform" style={{
    width: "20px",
    height: "32px",
    borderRadius: "4px",
    background: "#f8fafc",
    border: "1px solid #d1d5db",
    boxShadow: "0 1px 2px rgba(0,0,0,0.05)",
    transform: isDragging ? "scale(1.08)" : "scale(1)"
  }}>
                <div className="flex flex-col gap-0.5">
                  {[0, 1, 2].map(i => <div key={i} style={{
    width: "3px",
    height: "3px",
    borderRadius: "50%",
    background: "#0066ff"
  }} />)}
                </div>
                <div className="flex flex-col gap-0.5">
                  {[0, 1, 2].map(i => <div key={i} style={{
    width: "3px",
    height: "3px",
    borderRadius: "50%",
    background: "#0066ff"
  }} />)}
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </>;
};

export const CompressibleRentCalculator = () => {
  const [hours, setHours] = useState(24);
  const [lamportsPerWrite, setLamportsPerWrite] = useState(766);
  const [showCustomHours, setShowCustomHours] = useState(false);
  const [showCustomLamports, setShowCustomLamports] = useState(false);
  const [showFormula, setShowFormula] = useState(false);
  const DATA_LEN = 272;
  const BASE_RENT = 128;
  const LAMPORTS_PER_BYTE_PER_EPOCH = 1;
  const MINUTES_PER_EPOCH = 90;
  const COMPRESSION_COST = 11000;
  const LAMPORTS_PER_SOL = 1_000_000_000;
  const HOURS_MAX = 36;
  const LAMPORTS_MAX = 6400;
  const numEpochs = Math.ceil(hours * 60 / MINUTES_PER_EPOCH);
  const rentPerEpoch = BASE_RENT + DATA_LEN * LAMPORTS_PER_BYTE_PER_EPOCH;
  const totalPrepaidRent = rentPerEpoch * numEpochs;
  const totalCreationCost = totalPrepaidRent + COMPRESSION_COST;
  const handleHoursChange = value => {
    const num = Math.max(3, Math.min(168, Number.parseInt(value) || 3));
    setHours(num);
  };
  const handleLamportsChange = value => {
    const num = Math.max(0, Math.min(100000, Number.parseInt(value) || 0));
    setLamportsPerWrite(num);
  };
  const hoursPresets = [24];
  const lamportsPresets = [766];
  const SliderMarkers = ({max, step}) => {
    const marks = [];
    for (let i = step; i < max; i += step) {
      const percent = i / max * 100;
      marks.push(<div key={i} className="absolute top-1/2 -translate-y-1/2 w-px h-2 bg-zinc-300 dark:bg-white/30" style={{
        left: `${percent}%`
      }} />);
    }
    return <>{marks}</>;
  };
  return <div className="p-5 rounded-3xl not-prose mt-4 dark:bg-white/5 backdrop-blur-xl border border-black/[0.04] dark:border-white/10 shadow-lg" style={{
    fontFamily: "Inter, sans-serif"
  }}>
      <div className="space-y-5">
        {}
        <div className="space-y-2 px-3">
          <div className="flex justify-between items-center">
            <span className="text-sm text-zinc-700 dark:text-white/80">
              Prepaid Epochs in Hours
            </span>
            <div className="flex items-center gap-1.5">
              {hoursPresets.map(h => <button key={h} onClick={() => {
    setHours(h);
    setShowCustomHours(false);
  }} className={`px-2.5 py-1 text-xs font-medium rounded-lg border backdrop-blur-sm transition-all ${hours === h && !showCustomHours ? "bg-blue-500/20 border-blue-500/50 text-blue-600 dark:text-blue-400" : "bg-black/[0.015] dark:bg-white/5 border-black/[0.04] dark:border-white/20 text-zinc-600 dark:text-white/70 hover:bg-black/[0.03]"}`}>
                  {h === 24 ? "Default" : `${h}h`}
                </button>)}
              {showCustomHours ? <input type="number" min="3" max="168" value={hours} onChange={e => handleHoursChange(e.target.value)} className="w-16 px-2 py-1 text-right text-xs font-mono font-medium bg-blue-500/10 dark:bg-blue-500/20 border border-blue-500/50 rounded-lg backdrop-blur-sm focus:outline-none focus:ring-2 focus:ring-blue-500/50" autoFocus /> : <button onClick={() => setShowCustomHours(true)} className="px-2.5 py-1 text-xs font-medium rounded-lg border backdrop-blur-sm transition-all bg-black/[0.015] dark:bg-white/5 border-black/[0.04] dark:border-white/20 text-zinc-600 dark:text-white/70 hover:bg-black/[0.03]">
                  Custom
                </button>}
            </div>
          </div>
          <div className="flex items-center">
            <span className="w-1/3 text-xs text-zinc-500 dark:text-white/50 whitespace-nowrap">
              ≈ {(hours * 60 / MINUTES_PER_EPOCH).toFixed(1)} epochs / {hours.toFixed(1)}h
            </span>
            <div className="w-2/3 relative">
              <SliderMarkers max={HOURS_MAX} step={2} />
              <input type="range" min="3" max={HOURS_MAX} value={Math.min(hours, HOURS_MAX)} onChange={e => {
    setHours(Number.parseInt(e.target.value));
    setShowCustomHours(false);
  }} className="relative w-full h-1.5 bg-black/[0.03] dark:bg-white/20 rounded-full appearance-none cursor-pointer backdrop-blur-sm z-10" />
            </div>
          </div>
        </div>

        {}
        <div className="space-y-2 px-3">
          <div className="flex justify-between items-center">
            <span className="text-sm text-zinc-700 dark:text-white/80">Lamports per Write</span>
            <div className="flex items-center gap-1.5">
              {lamportsPresets.map(l => <button key={l} onClick={() => {
    setLamportsPerWrite(l);
    setShowCustomLamports(false);
  }} className={`px-2.5 py-1 text-xs font-medium rounded-lg border backdrop-blur-sm transition-all ${lamportsPerWrite === l && !showCustomLamports ? "bg-blue-500/20 border-blue-500/50 text-blue-600 dark:text-blue-400" : "bg-black/[0.015] dark:bg-white/5 border-black/[0.04] dark:border-white/20 text-zinc-600 dark:text-white/70 hover:bg-black/[0.03]"}`}>
                  {l === 766 ? "Default" : l.toLocaleString()}
                </button>)}
              {showCustomLamports ? <input type="number" min="0" max="100000" value={lamportsPerWrite} onChange={e => handleLamportsChange(e.target.value)} className="w-20 px-2 py-1 text-right text-xs font-mono font-medium bg-blue-500/10 dark:bg-blue-500/20 border border-blue-500/50 rounded-lg backdrop-blur-sm focus:outline-none focus:ring-2 focus:ring-blue-500/50" autoFocus /> : <button onClick={() => setShowCustomLamports(true)} className="px-2.5 py-1 text-xs font-medium rounded-lg border backdrop-blur-sm transition-all bg-black/[0.015] dark:bg-white/5 border-black/[0.04] dark:border-white/20 text-zinc-600 dark:text-white/70 hover:bg-black/[0.03]">
                  Custom
                </button>}
            </div>
          </div>
          <div className="flex items-center">
            <span className="w-1/3 text-xs text-zinc-500 dark:text-white/50 whitespace-nowrap">
              ≈ {(lamportsPerWrite / rentPerEpoch).toFixed(1)} epochs /{" "}
              {(lamportsPerWrite / rentPerEpoch * MINUTES_PER_EPOCH / 60).toFixed(1)}h
            </span>
            <div className="w-2/3 relative">
              <SliderMarkers max={LAMPORTS_MAX} step={800} />
              <input type="range" min="0" max={LAMPORTS_MAX} step="100" value={Math.min(lamportsPerWrite, LAMPORTS_MAX)} onChange={e => {
    setLamportsPerWrite(Number.parseInt(e.target.value));
    setShowCustomLamports(false);
  }} className="relative w-full h-1.5 bg-black/[0.03] dark:bg-white/20 rounded-full appearance-none cursor-pointer backdrop-blur-sm z-10" />
            </div>
          </div>
        </div>

        {}
        <div className="grid grid-cols-2 gap-3">
          <div className="p-4 bg-black/[0.015] dark:bg-white/5 backdrop-blur-md rounded-2xl text-center border border-black/[0.04] dark:border-white/10 shadow-sm">
            <div className="text-xs text-zinc-500 dark:text-white/50 mb-1 uppercase tracking-wide">
              Total Creation Cost
            </div>
            <div className="text-xl font-mono font-semibold text-zinc-900 dark:text-white">
              {totalCreationCost.toLocaleString()}
            </div>
            <div className="text-xs text-zinc-400 dark:text-white/40">lamports</div>
            <div className="text-xs text-zinc-500 dark:text-white/50 mt-1">
              ≈ {(totalCreationCost / LAMPORTS_PER_SOL).toFixed(6)} SOL
            </div>
          </div>

          <div className="p-4 bg-black/[0.015] dark:bg-white/5 backdrop-blur-md rounded-2xl text-center border border-black/[0.04] dark:border-white/10 shadow-sm">
            <div className="text-xs text-zinc-500 dark:text-white/50 mb-1 uppercase tracking-wide">
              Top-up Amount
            </div>
            <div className="text-xl font-mono font-semibold text-zinc-900 dark:text-white">
              {lamportsPerWrite.toLocaleString()}
            </div>
            <div className="text-xs text-zinc-400 dark:text-white/40">lamports</div>
            <div className="text-xs text-zinc-500 dark:text-white/50 mt-1">
              ≈ {(lamportsPerWrite / LAMPORTS_PER_SOL).toFixed(6)} SOL
            </div>
          </div>
        </div>

        {}
        <div className="pt-3 border-t border-black/[0.04] dark:border-white/10">
          <button onClick={() => setShowFormula(!showFormula)} className="flex items-center gap-2 text-xs text-zinc-500 dark:text-white/50 hover:text-zinc-700 dark:hover:text-white/70 transition-colors">
            <span className={`transition-transform ${showFormula ? "rotate-90" : ""}`}>▶</span>
            Show formula
          </button>
          {showFormula && <div className="text-xs font-mono text-zinc-500 dark:text-white/40 mt-3">
              <div className="text-zinc-600 dark:text-white/60 mb-2">
                Total cost for {DATA_LEN}-byte light-token account:
              </div>
              total_creation_cost = prepaid_rent + compression_cost
              <br />
              <br />
              rent_per_epoch = base_rent + (data_len × lamports_per_byte_per_epoch)
              <br />
              rent_per_epoch = {BASE_RENT} + ({DATA_LEN} × {LAMPORTS_PER_BYTE_PER_EPOCH}) ={" "}
              {rentPerEpoch} lamports
              <br />
              compression_cost = {COMPRESSION_COST.toLocaleString()} lamports
            </div>}
        </div>
      </div>
    </div>;
};

<table>
  <tbody>
    <tr>
      <td style={{ width: "33%" }}>**Light Token -> Light Token Account**</td>

      <td>
        <ul>
          <li>Transfers tokens between Light Token accounts</li>
        </ul>
      </td>
    </tr>

    <tr>
      <td>**Token 2022 / SPL token -> Light Token Account**</td>

      <td>
        <ul>
          <li>Transfers SPL tokens to Light Token accounts</li>
          <li>SPL / Token 2022 tokens are locked in interface PDA</li>
          <li>Tokens are minted to Light Token account</li>
        </ul>
      </td>
    </tr>

    <tr>
      <td>**Light Token -> SPL / Token 2022 Account**</td>

      <td>
        <ul>
          <li>Releases SPL / Token 2022 tokens from interface PDA to SPL account</li>
          <li>Burns tokens in source Light Token account</li>
        </ul>
      </td>
    </tr>
  </tbody>
</table>

<Accordion title="Agent skill">
  Install or view [dedicated agent skills](/ai-tools/overview#agent-skills).

  ```
  npx skills add Lightprotocol/skills
  ```

  Install orchestrator agent skill or view [skill.md](https://www.zkcompression.com/skill.md):

  ```bash theme={null}
  npx skills add https://zkcompression.com
  ```
</Accordion>

<Tabs>
  <Tab title="TypeScript Client">
    The `transferInterface` function transfers tokens between token accounts (SPL, Token 2022, or Light) in a single call and checks decimals.

    Compare to SPL:

    <CodeCompare firstCode={lightTransferCode} secondCode={splTransferCode} firstLabel="light-token" secondLabel="SPL" />

    <Info>
      Find the source code
      [here](https://github.com/Lightprotocol/light-protocol/blob/main/js/compressed-token/src/v3/actions/transfer-interface.ts).
    </Info>

    <Tabs>
      <Tab title="Guide">
        <Steps>
          <Step>
            ### Transfer Interface

            <Accordion title="Installation">
              <Tabs>
                <Tab title="npm">
                  Install packages in your working directory:

                  ```bash theme={null}
                  npm install @lightprotocol/stateless.js@^0.23.0 \
                              @lightprotocol/compressed-token@^0.23.0
                  ```

                  Install the CLI globally:

                  ```bash theme={null}
                  npm install -g @lightprotocol/zk-compression-cli
                  ```
                </Tab>

                <Tab title="yarn">
                  Install packages in your working directory:

                  ```bash theme={null}
                  yarn add @lightprotocol/stateless.js@^0.23.0 \
                           @lightprotocol/compressed-token@^0.23.0
                  ```

                  Install the CLI globally:

                  ```bash theme={null}
                  yarn global add @lightprotocol/zk-compression-cli
                  ```
                </Tab>

                <Tab title="pnpm">
                  Install packages in your working directory:

                  ```bash theme={null}
                  pnpm add @lightprotocol/stateless.js@^0.23.0 \
                           @lightprotocol/compressed-token@^0.23.0
                  ```

                  Install the CLI globally:

                  ```bash theme={null}
                  pnpm add -g @lightprotocol/zk-compression-cli
                  ```
                </Tab>

                <Tab title="SDK 2.0 (token-interface)">
                  Install packages in your working directory:

                  ```bash theme={null}
                  # npm
                  npm install @lightprotocol/stateless.js@^0.23.0 \
                              @lightprotocol/token-interface@^0.1.2

                  # yarn
                  yarn add @lightprotocol/stateless.js@^0.23.0 \
                           @lightprotocol/token-interface@^0.1.2

                  # pnpm
                  pnpm add @lightprotocol/stateless.js@^0.23.0 \
                           @lightprotocol/token-interface@^0.1.2
                  ```

                  Install the CLI globally:

                  ```bash theme={null}
                  npm install -g @lightprotocol/zk-compression-cli
                  ```
                </Tab>
              </Tabs>
            </Accordion>

            <Tabs>
              <Tab title="Localnet">
                ```bash theme={null}
                # start local test-validator in a separate terminal
                light test-validator
                ```

                <Note>
                  In the code examples, use `createRpc()` without arguments for localnet.
                </Note>
              </Tab>

              <Tab title="Devnet">
                Get an API key from [Helius](https://helius.dev) and add to `.env`:

                ```bash title=".env" theme={null}
                API_KEY=<your-helius-api-key>
                ```

                <Note>
                  In the code examples, use `createRpc(RPC_URL)` with the devnet URL.
                </Note>
              </Tab>
            </Tabs>

            <Tabs>
              <Tab title="Action">
                ```typescript theme={null}
                import "dotenv/config";
                import { Keypair } from "@solana/web3.js";
                import { createRpc } from "@lightprotocol/stateless.js";
                import {
                    createMintInterface,
                    createAtaInterface,
                    mintToInterface,
                    transferInterface,
                    getAssociatedTokenAddressInterface,
                } from "@lightprotocol/compressed-token";
                import { homedir } from "os";
                import { readFileSync } from "fs";

                // devnet:
                // const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`;
                // const rpc = createRpc(RPC_URL);
                // localnet:
                const rpc = createRpc();

                const payer = Keypair.fromSecretKey(
                    new Uint8Array(
                        JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8"))
                    )
                );

                (async function () {
                    const { mint } = await createMintInterface(rpc, payer, payer, null, 9);

                    const sender = Keypair.generate();
                    await createAtaInterface(rpc, payer, mint, sender.publicKey);
                    const senderAta = getAssociatedTokenAddressInterface(
                        mint,
                        sender.publicKey
                    );
                    await mintToInterface(rpc, payer, mint, senderAta, payer, 1_000_000_000);

                    const recipient = Keypair.generate();

                    // Recipient wallet; transferInterface creates recipient ATA idempotently
                    const tx = await transferInterface(
                        rpc,
                        payer,
                        senderAta,
                        mint,
                        recipient.publicKey,
                        sender.publicKey,
                        sender,
                        500_000_000
                    );

                    console.log("Tx:", tx);
                })();
                ```
              </Tab>

              <Tab title="Instruction">
                ```typescript theme={null}
                import "dotenv/config";
                import {
                    Keypair,
                    Transaction,
                    sendAndConfirmTransaction,
                } from "@solana/web3.js";
                import { createRpc } from "@lightprotocol/stateless.js";
                import {
                    createMintInterface,
                    createAtaInterface,
                    mintToInterface,
                    createLightTokenTransferInstruction,
                    getAssociatedTokenAddressInterface,
                } from "@lightprotocol/compressed-token";
                import { homedir } from "os";
                import { readFileSync } from "fs";

                // devnet:
                // const RPC_URL = `https://devnet.helius-rpc.com?api-key=${process.env.API_KEY!}`;
                // const rpc = createRpc(RPC_URL);
                // localnet:
                const rpc = createRpc();

                const payer = Keypair.fromSecretKey(
                    new Uint8Array(
                        JSON.parse(readFileSync(`${homedir()}/.config/solana/id.json`, "utf8"))
                    )
                );

                (async function () {
                    const { mint } = await createMintInterface(rpc, payer, payer, null, 9);

                    const sender = Keypair.generate();
                    await createAtaInterface(rpc, payer, mint, sender.publicKey);
                    const senderAta = getAssociatedTokenAddressInterface(
                        mint,
                        sender.publicKey
                    );
                    await mintToInterface(rpc, payer, mint, senderAta, payer, 1_000_000_000);

                    const recipient = Keypair.generate();
                    await createAtaInterface(rpc, payer, mint, recipient.publicKey);
                    const recipientAta = getAssociatedTokenAddressInterface(
                        mint,
                        recipient.publicKey
                    );

                    // Transfer tokens. Optional feePayer lets an application cover top-ups
                    // so the sender only signs to authorize the transfer.
                    const ix = createLightTokenTransferInstruction(
                        senderAta,
                        recipientAta,
                        sender.publicKey,     // owner (signs the transfer)
                        500_000_000,
                        payer.publicKey       // optional: separate feePayer covers top-up
                    );

                    const tx = new Transaction().add(ix);
                    const signature = await sendAndConfirmTransaction(rpc, tx, [payer, sender]);

                    console.log("Tx:", signature);
                })();
                ```
              </Tab>

              <Tab title="SDK 2.0 (token-interface)">
                ```typescript theme={null}
                import { Keypair, Transaction, sendAndConfirmTransaction } from "@solana/web3.js";
                import { createRpc } from "@lightprotocol/stateless.js";
                import { createTransferInstructions } from "@lightprotocol/token-interface";

                const rpc = createRpc();
                const payer = Keypair.fromSecretKey(/* ... */);

                const mint = /* existing mint public key */;
                const sourceOwner = Keypair.generate();
                const authority = sourceOwner; // delegate Keypair for delegated transfer
                const recipient = Keypair.generate();

                const transferIxs = await createTransferInstructions({
                  rpc,
                  payer: payer.publicKey,
                  mint,
                  sourceOwner: sourceOwner.publicKey,
                  authority: authority.publicKey,
                  recipient: recipient.publicKey,
                  amount: 500_000_000n,
                });

                const signature = await sendAndConfirmTransaction(
                  rpc,
                  new Transaction().add(...transferIxs),
                  [payer, authority]
                );
                console.log("Tx:", signature);
                ```
              </Tab>
            </Tabs>
          </Step>
        </Steps>
      </Tab>

      <Tab title="AI Prompt">
        <Prompt description="Transfer tokens between Light Token and SPL accounts" actions={["copy", "cursor"]}>
          {`---
                    description: Transfer tokens between Light Token and SPL accounts
                    allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
                    ---

                    ## Transfer tokens between Light Token and SPL accounts

                    Context:
                    - Guide: https://zkcompression.com/light-token/cookbook/transfer-interface
                    - Skills and resources index: https://zkcompression.com/skill.md
                    - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
                    - Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js

                    transferInterface() transfers tokens in a single call. The recipient parameter is a wallet public key.
                    Pass the source token-account owner pubkey and the signing authority separately: owner-signed flows use (owner.publicKey, owner); delegated flows use (owner.publicKey, delegate). Do not use removed InterfaceOptions.owner.
                    The SDK derives and creates the destination ATA internally. All transfers use transferChecked under the hood.
                    - Light Token → Light Token: transfers between Light Token accounts
                    - SPL → Light Token: locks SPL tokens in interface PDA, mints to Light Token account
                    - Light Token → SPL: burns Light Token balance, releases SPL tokens from interface PDA

                    Edge case: for explicit destination token accounts (PDA/program-owned), use transferToAccountInterface()
                    or createTransferToAccountInterfaceInstructions(). Most integrations should use transferInterface().

                    ### 1. Index project
                    - Grep \`@solana/spl-token|Connection|Keypair|transfer|transferInterface\` across src/
                    - Glob \`**/*.ts\` for project structure
                    - Identify: RPC setup, existing transfer logic, entry point for transfers
                    - Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel

                    ### 2. Read references
                    - WebFetch the guide above — follow the TypeScript Client tab
                    - WebFetch skill.md — check for a dedicated skill and resources matching this task
                    - TaskCreate one todo per phase below to track progress

                    ### 3. Clarify intention
                    - AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing)
                    - AskUserQuestion: does the project already have transfer operations to extend, or is this greenfield?
                    - Summarize findings and wait for user confirmation before implementing

                    ### 4. Create plan
                    - Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes
                    - Verify existing connection/signer setup is compatible with the cookbook prerequisites
                    - If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion)
                    - Present the plan to the user for approval before proceeding

                    ### 5. Implement
                    - Add deps if missing: Bash \`npm install @lightprotocol/compressed-token @lightprotocol/stateless.js\`
                    - Follow the cookbook guide and the approved plan
                    - Write/Edit to create or modify files
                    - TaskUpdate to mark each step done

                    ### 6. Verify
                    - Bash \`tsc --noEmit\`
                    - Bash run existing test suite if present
                    - TaskUpdate to mark complete

                    ### Tools
                    - mcp__zkcompression__SearchLightProtocol("<query>") for API details
                    - mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "<q>") for architecture
                    - Task subagent with Grep/Read/WebFetch for parallel lookups
                    - TaskList to check remaining work`}
        </Prompt>

        ```text theme={null}
        ---
        description: Transfer tokens between Light Token and SPL accounts
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Transfer tokens between Light Token and SPL accounts

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/transfer-interface
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Packages: @lightprotocol/compressed-token, @lightprotocol/stateless.js

        transferInterface() transfers tokens in a single call. The recipient parameter is a wallet public key.
        Pass the source token-account owner pubkey and the signing authority separately: owner-signed flows use (owner.publicKey, owner); delegated flows use (owner.publicKey, delegate). Do not use removed InterfaceOptions.owner.
        The SDK derives and creates the destination ATA internally. All transfers use transferChecked under the hood.
        - Light Token → Light Token: transfers between Light Token accounts
        - SPL → Light Token: locks SPL tokens in interface PDA, mints to Light Token account
        - Light Token → SPL: burns Light Token balance, releases SPL tokens from interface PDA

        Edge case: for explicit destination token accounts (PDA/program-owned), use transferToAccountInterface()
        or createTransferToAccountInterfaceInstructions(). Most integrations should use transferInterface().

        ### 1. Index project
        - Grep `@solana/spl-token|Connection|Keypair|transfer|transferInterface` across src/
        - Glob `**/*.ts` for project structure
        - Identify: RPC setup, existing transfer logic, entry point for transfers
        - Task subagent (Grep/Read/WebFetch) if project has multiple packages to scan in parallel

        ### 2. Read references
        - WebFetch the guide above — follow the TypeScript Client tab
        - WebFetch skill.md — check for a dedicated skill and resources matching this task
        - TaskCreate one todo per phase below to track progress

        ### 3. Clarify intention
        - AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing)
        - AskUserQuestion: does the project already have transfer operations to extend, or is this greenfield?
        - Summarize findings and wait for user confirmation before implementing

        ### 4. Create plan
        - Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes
        - Verify existing connection/signer setup is compatible with the cookbook prerequisites
        - If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion)
        - Present the plan to the user for approval before proceeding

        ### 5. Implement
        - Add deps if missing: Bash `npm install @lightprotocol/compressed-token @lightprotocol/stateless.js`
        - Follow the cookbook guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash `tsc --noEmit`
        - Bash run existing test suite if present
        - TaskUpdate to mark complete

        ### Tools
        - mcp__zkcompression__SearchLightProtocol("<query>") for API details
        - mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "<q>") for architecture
        - Task subagent with Grep/Read/WebFetch for parallel lookups
        - TaskList to check remaining work
        ```
      </Tab>
    </Tabs>

    ### Advanced: Explicit Destination Account

    For PDA destinations or program-owned accounts where you need to specify the exact destination token account, use `transferToAccountInterface`. This is an edge case; most transfers should use `transferInterface` with a wallet address.

    <Tabs>
      <Tab title="Action">
        ```typescript theme={null}
        import {
            transferToAccountInterface,
            getAssociatedTokenAddressInterface,
        } from "@lightprotocol/compressed-token";

        // The destination must be an existing token account (not a wallet address).
        await transferToAccountInterface(
            rpc,
            payer,
            sourceAta,
            mint,
            destinationTokenAccount,
            owner,
            amount,
        );
        ```
      </Tab>

      <Tab title="Instruction">
        ```typescript theme={null}
        import {
            createTransferToAccountInterfaceInstructions,
            getMintInterface,
            sliceLast,
        } from "@lightprotocol/compressed-token";

        const decimals = (await getMintInterface(rpc, mint)).mint.decimals;

        // Returns TransactionInstruction[][]. The destination must be an existing token account.
        const batches = await createTransferToAccountInterfaceInstructions(
            rpc,
            payer.publicKey,
            mint,
            amount,
            owner.publicKey,
            destinationTokenAccount,
            decimals,
        );

        const { rest: loads, last: transfer } = sliceLast(batches);
        ```
      </Tab>

      <Tab title="SDK 2.0 (token-interface)">
        ```typescript theme={null}
        import { Transaction, sendAndConfirmTransaction } from "@solana/web3.js";
        import {
          createTransferCheckedInstruction,
          createLoadInstructions,
        } from "@lightprotocol/token-interface";

        // The destination must be an existing token account.
        const destinationTokenAccount = /* existing ATA or program-owned token account */;
        const sourceAta = /* owner's Light ATA */;
        const decimals = 9;

        const loadIxs = await createLoadInstructions({
          rpc,
          payer: payer.publicKey,
          owner: owner.publicKey,
          mint,
          authority: owner.publicKey,
        });

        const transferIx = createTransferCheckedInstruction({
          source: sourceAta,
          destination: destinationTokenAccount,
          mint,
          authority: owner.publicKey,
          payer: payer.publicKey,
          amount: 500_000_000n,
          decimals,
        });

        const tx = new Transaction().add(...loadIxs, transferIx);
        await sendAndConfirmTransaction(rpc, tx, [payer, owner]);
        ```
      </Tab>
    </Tabs>
  </Tab>

  <Tab title="Rust Client">
    Use the unified `TransferInterface` to transfer tokens between token accounts (SPL, Token 2022, or Light) in a single call and checks decimals.

    <CodeCompare firstCode={lightTransferRustCode} secondCode={splTransferRustCode} firstLabel="light-token" secondLabel="SPL" language="rust" />

    <Tabs>
      <Tab title="Guide">
        <Steps>
          <Step>
            ### Prerequisites

            <Accordion title="Dependencies">
              ```toml Cargo.toml theme={null}
              [dependencies]
              light-token = "0.23.0"
              light-client = { version = "0.23.0", features = ["v2"] }
              solana-sdk = "2"
              borsh = "0.10.4"
              tokio = { version = "1", features = ["full"] }
              ```
            </Accordion>

            <Accordion title="Developer Environment">
              <Tabs>
                <Tab title="In-Memory (LightProgramTest)">
                  Test with Lite-SVM (...)

                  ```bash theme={null}
                  # Initialize project
                  cargo init my-light-project
                  cd my-light-project

                  # Run tests
                  cargo test
                  ```

                  ```rust theme={null}
                  use light_program_test::{LightProgramTest, ProgramTestConfig};
                  use solana_sdk::signer::Signer;

                  #[tokio::test]
                  async fn test_example() {
                      // In-memory test environment 
                      let mut rpc = LightProgramTest::new(ProgramTestConfig::default())
                          .await
                          .unwrap();

                      let payer = rpc.get_payer().insecure_clone();
                      println!("Payer: {}", payer.pubkey());
                  }
                  ```
                </Tab>

                <Tab title="Localnet (LightClient)">
                  Connects to a local test validator.

                  <Tabs>
                    <Tab title="npm">
                      ```bash theme={null}
                      npm install -g @lightprotocol/zk-compression-cli
                      ```
                    </Tab>

                    <Tab title="yarn">
                      ```bash theme={null}
                      yarn global add @lightprotocol/zk-compression-cli
                      ```
                    </Tab>

                    <Tab title="pnpm">
                      ```bash theme={null}
                      pnpm add -g @lightprotocol/zk-compression-cli
                      ```
                    </Tab>
                  </Tabs>

                  ```bash theme={null}
                  # Initialize project
                  cargo init my-light-project
                  cd my-light-project

                  # Start local test validator (in separate terminal)
                  light test-validator
                  ```

                  ```rust theme={null}
                  use light_client::rpc::{LightClient, LightClientConfig, Rpc};

                  #[tokio::main]
                  async fn main() -> Result<(), Box<dyn std::error::Error>> {
                      // Connects to http://localhost:8899
                      let rpc = LightClient::new(LightClientConfig::local()).await?;

                      let slot = rpc.get_slot().await?;
                      println!("Current slot: {}", slot);

                      Ok(())
                  }
                  ```
                </Tab>

                <Tab title="Devnet (LightClient)">
                  Replace `<your-api-key>` with your actual API key. [Get your API key here](https://www.helius.dev/zk-compression).

                  ```rust theme={null}
                  use light_client::rpc::{LightClient, LightClientConfig, Rpc};

                  #[tokio::main]
                  async fn main() -> Result<(), Box<dyn std::error::Error>> {
                      let rpc_url = "https://devnet.helius-rpc.com?api-key=<your_api_key>";
                      let rpc = LightClient::new(
                          LightClientConfig::new(rpc_url.to_string(), None, None)
                      ).await?;

                      println!("Connected to Devnet");
                      Ok(())
                  }
                  ```
                </Tab>
              </Tabs>
            </Accordion>
          </Step>

          <Step>
            ### Transfer Interface

            The example transfers

            1. SPL token -> Light Token,
            2. Light Token -> Light Token, and
            3. Light Token -> SPL token.

            <Info>
              Find the source code [here](https://github.com/Lightprotocol/light-protocol/blob/main/sdk-libs/token-sdk/src/instruction/transfer_interface.rs).
            </Info>

            <Tabs>
              <Tab title="Action">
                ```rust theme={null}
                use borsh::BorshDeserialize;
                use light_client::rpc::Rpc;
                use light_token_client::actions::{CreateAta, TransferInterface};
                use rust_client::{setup, SetupContext};
                use solana_sdk::{signature::Keypair, signer::Signer};

                #[tokio::main]
                async fn main() -> Result<(), Box<dyn std::error::Error>> {
                    let SetupContext {
                        mut rpc,
                        payer,
                        mint,
                        associated_token_account,
                        decimals,
                        ..
                    } = setup().await;

                    // Create recipient associated token account
                    let recipient = Keypair::new();
                    let (_signature, recipient_associated_token_account) = CreateAta {
                        mint,
                        owner: recipient.pubkey(),
                        idempotent: true,
                    }
                    .execute(&mut rpc, &payer)
                    .await?;

                    // Transfers tokens between token accounts (SPL, Token-2022, or Light) in a single call.
                    let sig = TransferInterface {
                        source: associated_token_account,
                        mint,
                        destination: recipient_associated_token_account,
                        amount: 1000,
                        decimals,
                        ..Default::default()
                    }
                    .execute(&mut rpc, &payer, &payer)
                    .await?;

                    let data = rpc
                        .get_account(recipient_associated_token_account)
                        .await?
                        .ok_or("Account not found")?;
                    let token = light_token_interface::state::Token::deserialize(&mut &data.data[..])?;
                    println!("Balance: {} Tx: {sig}", token.amount);

                    Ok(())
                }
                ```
              </Tab>

              <Tab title="Instruction">
                ```rust theme={null}
                use anchor_spl::token::spl_token;
                use borsh::BorshDeserialize;
                use light_client::rpc::Rpc;
                use light_program_test::{LightProgramTest, ProgramTestConfig};
                use light_token::{
                    instruction::{
                        get_associated_token_address, CreateAssociatedTokenAccount, SplInterface,
                        TransferInterface, LIGHT_TOKEN_PROGRAM_ID,
                    },
                    spl_interface::find_spl_interface_pda_with_index,
                };
                use rust_client::{setup_spl_associated_token_account, setup_spl_mint};
                use solana_sdk::signer::Signer;

                #[tokio::main]
                async fn main() -> Result<(), Box<dyn std::error::Error>> {
                    let mut rpc = LightProgramTest::new(ProgramTestConfig::new(true, None)).await?;

                    let payer = rpc.get_payer().insecure_clone();
                    let decimals = 2u8;
                    let amount = 10_000u64;

                    // Setup creates mint, mints tokens and creates SPL associated token account
                    let mint = setup_spl_mint(&mut rpc, &payer, decimals).await;
                    let spl_associated_token_account = setup_spl_associated_token_account(&mut rpc, &payer, &mint, &payer.pubkey(), amount).await;
                    let (interface_pda, interface_bump) = find_spl_interface_pda_with_index(&mint, 0, false);

                    // Create Light associated token account
                    let light_associated_token_account = get_associated_token_address(&payer.pubkey(), &mint);

                    let create_associated_token_account_instruction =
                        CreateAssociatedTokenAccount::new(payer.pubkey(), payer.pubkey(), mint).instruction()?;

                    rpc.create_and_send_transaction(&[create_associated_token_account_instruction], &payer.pubkey(), &[&payer])
                        .await?;

                    // SPL interface PDA for Mint (holds SPL tokens when transferred to Light Token)
                    let spl_interface = SplInterface {
                        mint,
                        spl_token_program: spl_token::ID,
                        spl_interface_pda: interface_pda,
                        spl_interface_pda_bump: interface_bump,
                    };

                    // Transfers tokens between token accounts (SPL, Token-2022, or Light) in a single call.
                    let transfer_instruction = TransferInterface {
                        source: spl_associated_token_account,
                        destination: light_associated_token_account,
                        amount,
                        decimals,
                        authority: payer.pubkey(),
                        payer: payer.pubkey(),
                        mint,
                        spl_interface: Some(spl_interface),
                        source_owner: spl_token::ID,
                        destination_owner: LIGHT_TOKEN_PROGRAM_ID,
                    }
                    .instruction()?;

                    let sig = rpc
                        .create_and_send_transaction(&[transfer_instruction], &payer.pubkey(), &[&payer])
                        .await?;

                    let data = rpc
                        .get_account(light_associated_token_account)
                        .await?
                        .ok_or("Account not found")?;
                    let token = light_token_interface::state::Token::deserialize(&mut &data.data[..])?;
                    println!("Balance: {} Tx: {sig}", token.amount);

                    Ok(())
                }
                ```
              </Tab>
            </Tabs>
          </Step>
        </Steps>
      </Tab>

      <Tab title="AI Prompt">
        <Prompt description="Transfer tokens between Light Token and SPL accounts" actions={["copy", "cursor"]}>
          {`---
                    description: Transfer tokens between Light Token and SPL accounts
                    allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
                    ---

                    ## Transfer tokens between Light Token and SPL accounts

                    Context:
                    - Guide: https://zkcompression.com/light-token/cookbook/transfer-interface
                    - Skills and resources index: https://zkcompression.com/skill.md
                    - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
                    - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

                    TransferInterface transfers tokens between token accounts (SPL, Token 2022, or Light Token) in a single call.
                    - Light Token → Light Token: transfers between Light Token accounts
                    - SPL → Light Token: locks SPL tokens in interface PDA, mints to Light Token account
                    - Light Token → SPL: burns Light Token balance, releases SPL tokens from interface PDA

                    SPL equivalent: spl_token::instruction::transfer → Light Token: TransferInterface

                    ### 1. Index project
                    - Grep \`light_token::|light_token_client::|solana_sdk|Keypair|async|TransferInterface|transfer\` across src/
                    - Glob \`**/*.rs\` for project structure
                    - Identify: RPC setup, existing token ops, entry point for transfers
                    - Check Cargo.toml for existing light-* dependencies and solana-sdk version
                    - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

                    ### 2. Read references
                    - WebFetch the guide above — follow the Rust Client tab
                    - WebFetch skill.md — check for a dedicated skill and resources matching this task
                    - TaskCreate one todo per phase below to track progress

                    ### 3. Clarify intention
                    - AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing)
                    - AskUserQuestion: does the project already have transfer operations to extend, or is this greenfield?
                    - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
                    - Summarize findings and wait for user confirmation before implementing

                    ### 4. Create plan
                    - Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes
                    - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
                    - If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion)
                    - Present the plan to the user for approval before proceeding

                    ### 5. Implement
                    - Add deps if missing: Bash \`cargo add light-token-client light-token light-client --features light-client/v2\`
                    - Follow the cookbook guide and the approved plan
                    - Write/Edit to create or modify files
                    - TaskUpdate to mark each step done

                    ### 6. Verify
                    - Bash \`cargo check\`
                    - Bash \`cargo test\` if tests exist
                    - TaskUpdate to mark complete

                    ### Tools
                    - mcp__zkcompression__SearchLightProtocol("<query>") for API details
                    - mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "<q>") for architecture
                    - Task subagent with Grep/Read/WebFetch for parallel lookups
                    - TaskList to check remaining work`}
        </Prompt>

        ```text theme={null}
        ---
        description: Transfer tokens between Light Token and SPL accounts
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Transfer tokens between Light Token and SPL accounts

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/transfer-interface
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crates: light-token-client (actions), light-token (instructions), light-client (RPC)

        TransferInterface transfers tokens between token accounts (SPL, Token 2022, or Light Token) in a single call.
        - Light Token → Light Token: transfers between Light Token accounts
        - SPL → Light Token: locks SPL tokens in interface PDA, mints to Light Token account
        - Light Token → SPL: burns Light Token balance, releases SPL tokens from interface PDA

        SPL equivalent: spl_token::instruction::transfer → Light Token: TransferInterface

        ### 1. Index project
        - Grep `light_token::|light_token_client::|solana_sdk|Keypair|async|TransferInterface|transfer` across src/
        - Glob `**/*.rs` for project structure
        - Identify: RPC setup, existing token ops, entry point for transfers
        - Check Cargo.toml for existing light-* dependencies and solana-sdk version
        - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

        ### 2. Read references
        - WebFetch the guide above — follow the Rust Client tab
        - WebFetch skill.md — check for a dedicated skill and resources matching this task
        - TaskCreate one todo per phase below to track progress

        ### 3. Clarify intention
        - AskUserQuestion: what is the goal? (new feature, migrate existing SPL code, add alongside existing)
        - AskUserQuestion: does the project already have transfer operations to extend, or is this greenfield?
        - AskUserQuestion: action-level API (high-level, fewer lines) or instruction-level API (low-level, full control)?
        - Summarize findings and wait for user confirmation before implementing

        ### 4. Create plan
        - Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes
        - Verify existing Rpc/signer setup is compatible with the cookbook prerequisites (light_client::rpc::Rpc, solana_sdk::signature::Keypair)
        - If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion)
        - Present the plan to the user for approval before proceeding

        ### 5. Implement
        - Add deps if missing: Bash `cargo add light-token-client light-token light-client --features light-client/v2`
        - Follow the cookbook guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash `cargo check`
        - Bash `cargo test` if tests exist
        - TaskUpdate to mark complete

        ### Tools
        - mcp__zkcompression__SearchLightProtocol("<query>") for API details
        - mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "<q>") for architecture
        - Task subagent with Grep/Read/WebFetch for parallel lookups
        - TaskList to check remaining work
        ```
      </Tab>
    </Tabs>
  </Tab>

  <Tab title="Program">
    <Tabs>
      <Tab title="Guide">
        <Note>
          Find [a full code example at the end](#full-code-example).
        </Note>

        <Steps>
          <Step>
            ### Transfer Interface CPI

            The `TransferInterfaceCpi` transfers tokens between token accounts (SPL, Token 2022, or Light Token).

            <Tabs>
              <Tab title="invoke (External signer)">
                ```rust theme={null}
                use light_token::instruction::TransferInterfaceCpi;

                TransferInterfaceCpi::new(
                    amount,
                    decimals,
                    source.clone(),
                    destination.clone(),
                    authority.clone(),
                    payer.clone(),
                    light_token_authority.clone(),
                    system_program.clone(),
                )
                .invoke()?;
                ```
              </Tab>

              <Tab title="invoke_signed (PDA signer)">
                ```rust theme={null}
                use light_token::instruction::TransferInterfaceCpi;

                let signer_seeds = authority_seeds!(bump);

                TransferInterfaceCpi::new(
                    amount,
                    decimals,
                    source.clone(),
                    destination.clone(),
                    authority.clone(),
                    payer.clone(),
                    light_token_authority.clone(),
                    system_program.clone(),
                )
                .invoke_signed(&[signer_seeds])?;
                ```
              </Tab>
            </Tabs>
          </Step>
        </Steps>

        # Full code example

        <Tabs>
          <Tab title="CPI">
            <Info>
              View the [source code](https://github.com/Lightprotocol/light-protocol/blob/main/sdk-libs/token-sdk/src/instruction/transfer_interface.rs) and [full example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/transfer-interface) with shared test utilities.
            </Info>

            <CodeGroup>
              ```rust lib.rs theme={null}
              #![allow(unexpected_cfgs, deprecated)]

              use anchor_lang::prelude::*;
              use light_token::instruction::TransferInterfaceCpi;

              declare_id!("3rb6sG4jiYNLZC8jo8kLsFHpxr2Ci8e8Hh8UmeCMZmUV");

              #[program]
              pub mod light_token_anchor_transfer_interface {
                  use super::*;

                  pub fn transfer(
                      ctx: Context<TransferAccounts>,
                      amount: u64,
                      decimals: u8,
                      spl_interface_pda_bump: Option<u8>,
                  ) -> Result<()> {
                      let mut transfer = TransferInterfaceCpi::new(
                          amount,
                          decimals,
                          ctx.accounts.source.to_account_info(),
                          ctx.accounts.destination.to_account_info(),
                          ctx.accounts.authority.to_account_info(),
                          ctx.accounts.payer.to_account_info(),
                          ctx.accounts.cpi_authority.to_account_info(),
                          ctx.accounts.mint.to_account_info(),
                          ctx.accounts.system_program.to_account_info(),
                      );

                      if let Some(bump) = spl_interface_pda_bump {
                          transfer = transfer
                              .with_spl_interface(
                                  Some(ctx.accounts.mint.to_account_info()),
                                  ctx.accounts
                                      .spl_token_program
                                      .as_ref()
                                      .map(|a| a.to_account_info()),
                                  ctx.accounts
                                      .spl_interface_pda
                                      .as_ref()
                                      .map(|a| a.to_account_info()),
                                  Some(bump),
                              )
                              ?;
                      }

                      transfer.invoke()?;
                      Ok(())
                  }
              }

              #[derive(Accounts)]
              pub struct TransferAccounts<'info> {
                  /// CHECK: Light token program for CPI
                  pub light_token_program: AccountInfo<'info>,
                  /// CHECK: Validated by light-token CPI
                  #[account(mut)]
                  pub source: AccountInfo<'info>,
                  /// CHECK: Validated by light-token CPI
                  #[account(mut)]
                  pub destination: AccountInfo<'info>,
                  pub authority: Signer<'info>,
                  #[account(mut)]
                  pub payer: Signer<'info>,
                  /// CHECK: Validated by light-token CPI
                  pub cpi_authority: AccountInfo<'info>,
                  pub system_program: Program<'info, System>,

                  /// CHECK: Validated by light-token CPI - token mint
                  pub mint: AccountInfo<'info>,
                  // SPL interface accounts (optional, for cross-type transfers)
                  /// CHECK: SPL Token or Token-2022 program
                  pub spl_token_program: Option<AccountInfo<'info>>,
                  /// CHECK: Validated by light-token CPI - pool PDA
                  #[account(mut)]
                  pub spl_interface_pda: Option<AccountInfo<'info>>,
              }
              ```

              ```rust test.rs theme={null}
              use anchor_lang::system_program;
              use anchor_lang::{InstructionData, ToAccountMetas};
              use anchor_spl::token::{spl_token, Mint};
              use light_program_test::Rpc;
              use solana_sdk::program_pack::Pack as _;
              use light_token::instruction::{
                  derive_token_ata, CreateAssociatedTokenAccount, LIGHT_TOKEN_PROGRAM_ID,
              };
              use light_token::spl_interface::{find_spl_interface_pda_with_index, CreateSplInterfacePda};
              use light_token_anchor_transfer_interface::{accounts, instruction::Transfer, ID};
              use light_token_types::CPI_AUTHORITY_PDA;
              use solana_sdk::{
                  instruction::Instruction,
                  pubkey::Pubkey,
                  signature::Keypair,
                  signer::Signer,
              };
              use test_utils::{create_associated_token_account_for_owner, mint_tokens, setup_test_env};

              #[tokio::test]
              async fn test_transfer() {
                  let mut env = setup_test_env("light_token_anchor_transfer_interface", ID).await;
                  mint_tokens(&mut env.rpc, &env.payer, env.mint_pda, env.associated_token_account, 1_000_000).await;

                  // Create destination associated token account for recipient
                  let recipient = Keypair::new();
                  let dest_associated_token_account =
                      create_associated_token_account_for_owner(&mut env.rpc, &env.payer, &recipient.pubkey(), &env.mint_pda).await;

                  // Transfers tokens between accounts (SPL, Token-2022, or Light) in a single call.
                  let transfer_amount = 100_000u64;
                  let decimals = 9u8;
                  let cpi_authority_pda = Pubkey::new_from_array(CPI_AUTHORITY_PDA);

                  let ix = Instruction {
                      program_id: ID,
                      accounts: accounts::TransferAccounts {
                          light_token_program: LIGHT_TOKEN_PROGRAM_ID,
                          source: env.associated_token_account,
                          destination: dest_associated_token_account,
                          authority: env.payer.pubkey(),
                          payer: env.payer.pubkey(),
                          cpi_authority: cpi_authority_pda,
                          system_program: system_program::ID,
                          mint: env.mint_pda,
                          spl_token_program: None,
                          spl_interface_pda: None,
                      }
                      .to_account_metas(Some(true)),
                      data: Transfer {
                          amount: transfer_amount,
                          decimals,
                          spl_interface_pda_bump: None,
                      }
                      .data(),
                  };

                  let sig = env
                      .rpc
                      .create_and_send_transaction(&[ix], &env.payer.pubkey(), &[&env.payer])
                      .await
                      .unwrap();

                  println!("Tx: {}", sig);
              }

              #[tokio::test]
              async fn test_transfer_spl_to_light() {
                  let mut env = setup_test_env("light_token_anchor_transfer_interface", ID).await;

                  let payer = env.payer.insecure_clone();
                  let cpi_authority_pda = Pubkey::new_from_array(CPI_AUTHORITY_PDA);

                  // 1. Create SPL mint
                  let mint_keypair = Keypair::new();
                  let mint = mint_keypair.pubkey();
                  let decimals = 9u8;

                  let mint_rent = env
                      .rpc
                      .get_minimum_balance_for_rent_exemption(Mint::LEN)
                      .await
                      .unwrap();

                  let create_mint_account_ix = solana_sdk::system_instruction::create_account(
                      &payer.pubkey(),
                      &mint,
                      mint_rent,
                      Mint::LEN as u64,
                      &spl_token::ID,
                  );

                  let initialize_mint_ix = spl_token::instruction::initialize_mint(
                      &spl_token::ID,
                      &mint,
                      &payer.pubkey(),
                      None,
                      decimals,
                  )
                  .unwrap();

                  env.rpc
                      .create_and_send_transaction(
                          &[create_mint_account_ix, initialize_mint_ix],
                          &payer.pubkey(),
                          &[&payer, &mint_keypair],
                      )
                      .await
                      .unwrap();

                  // 2. Create SPL token pool (spl_interface_pda)
                  let create_pool_ix =
                      CreateSplInterfacePda::new(payer.pubkey(), mint, spl_token::ID, false).instruction();

                  env.rpc
                      .create_and_send_transaction(&[create_pool_ix], &payer.pubkey(), &[&payer])
                      .await
                      .unwrap();

                  // 3. Create SPL token account and mint tokens
                  let spl_account_keypair = Keypair::new();
                  let spl_account = spl_account_keypair.pubkey();

                  let spl_account_rent = env
                      .rpc
                      .get_minimum_balance_for_rent_exemption(spl_token::state::Account::LEN)
                      .await
                      .unwrap();

                  let create_spl_account_ix = solana_sdk::system_instruction::create_account(
                      &payer.pubkey(),
                      &spl_account,
                      spl_account_rent,
                      spl_token::state::Account::LEN as u64,
                      &spl_token::ID,
                  );

                  let init_spl_account_ix = spl_token::instruction::initialize_account(
                      &spl_token::ID,
                      &spl_account,
                      &mint,
                      &payer.pubkey(),
                  )
                  .unwrap();

                  let mint_amount = 1_000_000u64;
                  let mint_to_ix = spl_token::instruction::mint_to(
                      &spl_token::ID,
                      &mint,
                      &spl_account,
                      &payer.pubkey(),
                      &[],
                      mint_amount,
                  )
                  .unwrap();

                  env.rpc
                      .create_and_send_transaction(
                          &[create_spl_account_ix, init_spl_account_ix, mint_to_ix],
                          &payer.pubkey(),
                          &[&payer, &spl_account_keypair],
                      )
                      .await
                      .unwrap();

                  // 4. Create Light ATA for destination
                  let recipient = Keypair::new();
                  let dest_ata = derive_token_ata(&recipient.pubkey(), &mint);
                  let create_ata_ix = CreateAssociatedTokenAccount::new(payer.pubkey(), recipient.pubkey(), mint)
                      .instruction()
                      .unwrap();

                  env.rpc
                      .create_and_send_transaction(&[create_ata_ix], &payer.pubkey(), &[&payer])
                      .await
                      .unwrap();

                  // 5. Transfer SPL tokens to Light ATA via transfer-interface
                  let transfer_amount = 100_000u64;
                  let (spl_interface_pda, spl_interface_pda_bump) =
                      find_spl_interface_pda_with_index(&mint, 0, false);

                  let ix = Instruction {
                      program_id: ID,
                      accounts: accounts::TransferAccounts {
                          light_token_program: LIGHT_TOKEN_PROGRAM_ID,
                          source: spl_account,
                          destination: dest_ata,
                          authority: payer.pubkey(),
                          payer: payer.pubkey(),
                          cpi_authority: cpi_authority_pda,
                          system_program: system_program::ID,
                          mint: mint,
                          spl_token_program: Some(spl_token::ID),
                          spl_interface_pda: Some(spl_interface_pda),
                      }
                      .to_account_metas(Some(true)),
                      data: Transfer {
                          amount: transfer_amount,
                          decimals,
                          spl_interface_pda_bump: Some(spl_interface_pda_bump),
                      }
                      .data(),
                  };

                  let sig = env
                      .rpc
                      .create_and_send_transaction(&[ix], &payer.pubkey(), &[&payer])
                      .await
                      .unwrap();

                  println!("Tx: {}", sig);
              }
              ```
            </CodeGroup>
          </Tab>

          <Tab title="Setup ATA with Macro and CPI">
            Uses the `#[light_account(init, associated_token::...)]` macro to create the destination ATA during the transfer.

            <Info>
              View the [full example](https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/create-and-transfer) with test utilities.
            </Info>

            <CodeGroup>
              ```rust lib.rs theme={null}
              #![allow(unexpected_cfgs, deprecated)]

              use anchor_lang::prelude::*;
              use light_sdk::interface::CreateAccountsProof;
              use light_token::anchor::{derive_light_cpi_signer, light_program, CpiSigner, LightAccounts};
              use light_token::instruction::TransferInterfaceCpi;

              declare_id!("672fL1Nm191MbPoygNM9DRiG2psBELn97XUpGbU3jW7E");

              pub const LIGHT_CPI_SIGNER: CpiSigner =
                  derive_light_cpi_signer!("672fL1Nm191MbPoygNM9DRiG2psBELn97XUpGbU3jW7E");

              #[derive(AnchorSerialize, AnchorDeserialize, Clone)]
              pub struct TransferParams {
                  pub create_accounts_proof: CreateAccountsProof,
                  pub dest_associated_token_account_bump: u8,
                  pub amount: u64,
                  pub decimals: u8,
              }

              #[light_program]
              #[program]
              pub mod create_and_transfer {
                  use super::*;

                  pub fn transfer<'info>(
                      ctx: Context<'_, '_, '_, 'info, Transfer<'info>>,
                      params: TransferParams,
                  ) -> Result<()> {
                      TransferInterfaceCpi::new(
                          params.amount,
                          params.decimals,
                          ctx.accounts.source.to_account_info(),
                          ctx.accounts.destination.to_account_info(),
                          ctx.accounts.authority.to_account_info(),
                          ctx.accounts.payer.to_account_info(),
                          ctx.accounts.light_token_cpi_authority.to_account_info(),
                          ctx.accounts.system_program.to_account_info(),
                      )
                      .invoke()
                      .map_err(|e| anchor_lang::prelude::ProgramError::from(e))?;
                      Ok(())
                  }
              }

              #[derive(Accounts, LightAccounts)]
              #[instruction(params: TransferParams)]
              pub struct Transfer<'info> {
                  #[account(mut)]
                  pub payer: Signer<'info>,

                  pub authority: Signer<'info>,

                  /// CHECK: Validated by light-token CPI
                  pub mint: AccountInfo<'info>,

                  /// CHECK: Validated by light-token CPI
                  #[account(mut)]
                  pub source: AccountInfo<'info>,

                  /// CHECK: Validated by light-token CPI
                  pub recipient: AccountInfo<'info>,

                  /// CHECK: Validated by light-token CPI
                  #[account(mut)]
                  #[light_account(init,
                      associated_token::authority = recipient,
                      associated_token::mint = mint,
                      associated_token::bump = params.dest_associated_token_account_bump
                  )]
                  pub destination: UncheckedAccount<'info>,

                  /// CHECK: Validated by light-token CPI
                  pub light_token_program: AccountInfo<'info>,

                  pub system_program: Program<'info, System>,

                  /// CHECK: Validated by light-token CPI
                  pub light_token_compressible_config: AccountInfo<'info>,

                  /// CHECK: Validated by light-token CPI
                  #[account(mut)]
                  pub rent_sponsor: AccountInfo<'info>,

                  /// CHECK: Validated by light-token CPI
                  pub light_token_cpi_authority: AccountInfo<'info>,
              }
              ```

              ```rust test.rs theme={null}
              use anchor_lang::{InstructionData, ToAccountMetas};
              use light_client::interface::{get_create_accounts_proof, InitializeRentFreeConfig};
              use light_program_test::{
                  program_test::{setup_mock_program_data, LightProgramTest},
                  Indexer, ProgramTestConfig, Rpc,
              };
              use light_sdk_types::LIGHT_TOKEN_PROGRAM_ID;
              use light_token::instruction::{
                  derive_token_ata, find_mint_address, COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR,
              };
              use solana_instruction::Instruction;
              use solana_keypair::Keypair;
              use solana_signer::Signer;
              use create_and_transfer::{TransferParams, ID};

              #[tokio::test]
              async fn test_transfer() {
                  let config = ProgramTestConfig::new_v2(true, Some(vec![("create_and_transfer", ID)]))
                      .with_light_protocol_events();

                  let mut rpc = LightProgramTest::new(config).await.unwrap();
                  let payer = rpc.get_payer().insecure_clone();

                  let program_data_pda = setup_mock_program_data(&mut rpc, &payer, &ID);

                  let (init_config_ix, _config_pda) = InitializeRentFreeConfig::new(
                      &ID,
                      &payer.pubkey(),
                      &program_data_pda,
                      RENT_SPONSOR,
                      payer.pubkey(),
                  )
                  .build();

                  rpc.create_and_send_transaction(&[init_config_ix], &payer.pubkey(), &[&payer])
                      .await
                      .unwrap();

                  let (mint_pda, _mint_seed) = setup_create_mint(
                      &mut rpc,
                      &payer,
                      payer.pubkey(), // mint_authority
                      9,              // decimals
                  )
                  .await;

                  println!("Mint created at: {}", mint_pda);

                  let sender = Keypair::new();
                  let (sender_associated_token_account, _sender_associated_token_account_bump) =
                      derive_token_ata(&sender.pubkey(), &mint_pda);

                  let create_sender_associated_token_account_ix =
                      light_token::instruction::CreateAssociatedTokenAccount::new(
                          payer.pubkey(),
                          sender.pubkey(),
                          mint_pda,
                      )
                      .instruction()
                      .unwrap();

                  rpc.create_and_send_transaction(
                      &[create_sender_associated_token_account_ix],
                      &payer.pubkey(),
                      &[&payer],
                  )
                  .await
                  .unwrap();

                  let mint_amount: u64 = 1_000_000_000;
                  mint_tokens(&mut rpc, &payer, mint_pda, sender_associated_token_account, mint_amount).await;

                  println!(
                      "Minted {} tokens to sender: {}",
                      mint_amount, sender_associated_token_account
                  );

                  let recipient = Keypair::new();
                  let (recipient_associated_token_account, recipient_associated_token_account_bump) =
                      derive_token_ata(&recipient.pubkey(), &mint_pda);

                  let transfer_proof_result = get_create_accounts_proof(&rpc, &ID, vec![]).await.unwrap();

                  let transfer_accounts = create_and_transfer::accounts::Transfer {
                      payer: payer.pubkey(),
                      authority: sender.pubkey(),
                      mint: mint_pda,
                      source: sender_associated_token_account,
                      recipient: recipient.pubkey(),
                      destination: recipient_associated_token_account,
                      light_token_program: LIGHT_TOKEN_PROGRAM_ID.into(),
                      system_program: solana_sdk::system_program::ID,
                      light_token_compressible_config: COMPRESSIBLE_CONFIG_V1,
                      rent_sponsor: RENT_SPONSOR,
                      light_token_cpi_authority: light_token_types::CPI_AUTHORITY_PDA.into(),
                  };

                  let transfer_amount: u64 = 500_000_000; // 0.5 tokens
                  let decimals: u8 = 9;

                  let transfer_ix = Instruction {
                      program_id: ID,
                      accounts: [
                          transfer_accounts.to_account_metas(None),
                          transfer_proof_result.remaining_accounts,
                      ]
                      .concat(),
                      data: create_and_transfer::instruction::Transfer {
                          params: TransferParams {
                              create_accounts_proof: transfer_proof_result.create_accounts_proof,
                              dest_associated_token_account_bump: recipient_associated_token_account_bump,
                              amount: transfer_amount,
                              decimals,
                          },
                      }
                      .data(),
                  };

                  let sig = rpc
                      .create_and_send_transaction(&[transfer_ix], &payer.pubkey(), &[&payer, &sender])
                      .await
                      .unwrap();

                  println!("Transfer Tx: {}", sig);

                  use light_token_interface::state::Token;

                  let recipient_account = rpc
                      .get_account(recipient_associated_token_account)
                      .await
                      .unwrap()
                      .unwrap();
                  let recipient_token: Token =
                      borsh::BorshDeserialize::deserialize(&mut &recipient_account.data[..]).unwrap();

                  assert_eq!(recipient_token.amount, transfer_amount);
                  assert_eq!(recipient_token.owner, recipient.pubkey().to_bytes());

                  println!(
                      "Recipient balance: {}, owner: {}",
                      recipient_token.amount,
                      recipient.pubkey()
                  );

                  let sender_account = rpc
                      .get_account(sender_associated_token_account)
                      .await
                      .unwrap()
                      .unwrap();
                  let sender_token: Token =
                      borsh::BorshDeserialize::deserialize(&mut &sender_account.data[..]).unwrap();

                  assert_eq!(sender_token.amount, mint_amount - transfer_amount);
                  println!("Sender remaining balance: {}", sender_token.amount);
              }
              ```
            </CodeGroup>
          </Tab>
        </Tabs>
      </Tab>

      <Tab title="AI Prompt">
        <Prompt description="Add transfer-interface CPI to an Anchor program" actions={["copy", "cursor"]}>
          {`---
                    description: Add transfer-interface CPI to an Anchor program
                    allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
                    ---

                    ## Add transfer-interface CPI to an Anchor program

                    Context:
                    - Guide: https://zkcompression.com/light-token/cookbook/transfer-interface
                    - Skills and resources index: https://zkcompression.com/skill.md
                    - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
                    - Crate: light-token (TransferInterfaceCpi)
                    - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/transfer-interface

                    Key CPI struct: \`light_token::instruction::TransferInterfaceCpi\`

                    ### 1. Index project
                    - Grep \`declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|transfer|decimals|interface\` across src/
                    - Glob \`**/*.rs\` and \`**/Cargo.toml\` for project structure
                    - Identify: program ID, existing instructions, account structs, token accounts
                    - Read Cargo.toml — note existing dependencies and framework version
                    - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

                    ### 2. Read references
                    - WebFetch the guide above — review the Program tab CPI code samples
                    - WebFetch skill.md — check for a dedicated skill and resources matching this task
                    - TaskCreate one todo per phase below to track progress

                    ### 3. Clarify intention
                    - AskUserQuestion: what is the goal? (add transfer-interface to existing program, new program from scratch, migrate from SPL transfer)
                    - AskUserQuestion: should the authority be an external signer or a PDA? (determines invoke vs invoke_signed)
                    - AskUserQuestion: which token types will be transferred? (SPL, Token 2022, Light Token, or all via interface)
                    - Summarize findings and wait for user confirmation before implementing

                    ### 4. Create plan
                    - Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes
                    - Follow the guide's step order: Build TransferInterfaceCpi → call .invoke() or .invoke_signed()
                    - If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion)
                    - Present the plan to the user for approval before proceeding

                    ### 5. Implement
                    - Add deps if missing: Bash \`cargo add light-token anchor-lang@0.31\`
                    - Follow the guide and the approved plan
                    - Write/Edit to create or modify files
                    - TaskUpdate to mark each step done

                    ### 6. Verify
                    - Bash \`anchor build\`
                    - Bash \`anchor test\` if tests exist
                    - TaskUpdate to mark complete

                    ### Tools
                    - mcp__zkcompression__SearchLightProtocol("<query>") for API details
                    - mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "<q>") for architecture
                    - Task subagent with Grep/Read/WebFetch for parallel lookups
                    - TaskList to check remaining work`}
        </Prompt>

        ```text theme={null}
        ---
        description: Add transfer-interface CPI to an Anchor program
        allowed-tools: Bash, Read, Write, Edit, Glob, Grep, WebFetch, AskUserQuestion, Task, TaskCreate, TaskGet, TaskList, TaskUpdate, TaskOutput, mcp__deepwiki, mcp__zkcompression
        ---

        ## Add transfer-interface CPI to an Anchor program

        Context:
        - Guide: https://zkcompression.com/light-token/cookbook/transfer-interface
        - Skills and resources index: https://zkcompression.com/skill.md
        - SPL to Light reference: https://zkcompression.com/api-reference/solana-to-light-comparison
        - Crate: light-token (TransferInterfaceCpi)
        - Example: https://github.com/Lightprotocol/examples-light-token/tree/main/programs/anchor/basic-instructions/transfer-interface

        Key CPI struct: `light_token::instruction::TransferInterfaceCpi`

        ### 1. Index project
        - Grep `declare_id|#\[program\]|anchor_lang|Account<|Pubkey|invoke|transfer|decimals|interface` across src/
        - Glob `**/*.rs` and `**/Cargo.toml` for project structure
        - Identify: program ID, existing instructions, account structs, token accounts
        - Read Cargo.toml — note existing dependencies and framework version
        - Task subagent (Grep/Read/WebFetch) if project has multiple crates to scan in parallel

        ### 2. Read references
        - WebFetch the guide above — review the Program tab CPI code samples
        - WebFetch skill.md — check for a dedicated skill and resources matching this task
        - TaskCreate one todo per phase below to track progress

        ### 3. Clarify intention
        - AskUserQuestion: what is the goal? (add transfer-interface to existing program, new program from scratch, migrate from SPL transfer)
        - AskUserQuestion: should the authority be an external signer or a PDA? (determines invoke vs invoke_signed)
        - AskUserQuestion: which token types will be transferred? (SPL, Token 2022, Light Token, or all via interface)
        - Summarize findings and wait for user confirmation before implementing

        ### 4. Create plan
        - Based on steps 1–3, draft an implementation plan: which files to modify, what code to add, dependency changes
        - Follow the guide's step order: Build TransferInterfaceCpi → call .invoke() or .invoke_signed()
        - If anything is unclear or ambiguous, loop back to step 3 (AskUserQuestion)
        - Present the plan to the user for approval before proceeding

        ### 5. Implement
        - Add deps if missing: Bash `cargo add light-token anchor-lang@0.31`
        - Follow the guide and the approved plan
        - Write/Edit to create or modify files
        - TaskUpdate to mark each step done

        ### 6. Verify
        - Bash `anchor build`
        - Bash `anchor test` if tests exist
        - TaskUpdate to mark complete

        ### Tools
        - mcp__zkcompression__SearchLightProtocol("<query>") for API details
        - mcp__deepwiki__ask_question("Lightprotocol/light-protocol", "<q>") for architecture
        - Task subagent with Grep/Read/WebFetch for parallel lookups
        - TaskList to check remaining work
        ```
      </Tab>
    </Tabs>
  </Tab>
</Tabs>

## Related Guides

<CardGroup cols={2}>
  <Card title="Wrap and unwrap" icon="rotate" href="/light-token/cookbook/wrap-unwrap" horizontal />

  <Card title="Payments overview" icon="credit-card" href="/light-token/payments/overview" horizontal />
</CardGroup>

***

## Didn't find what you were looking for?

<Callout type="info">
  Reach out! [Telegram](https://t.me/swen_light) | [email](mailto:support@lightprotocol.com) | [Discord](https://discord.com/invite/7cJ8BhAXhu)
</Callout>
